PHP, MYSQL and displaying static links instead of coded links

Discussion in 'PHP' started by dlow123, Feb 5, 2007.

  1. #1
    Hello,

    I am working with a script to display images on a pixel site. I am trying to remove the function that displays a dynamic link and have the links instead show as static. The current code that the script uses is as follows:

    $sql = "select id,url,x1,y1,x2,y2,title,img_name from area where cnf_check='1' and mouseover_mode='TEXT' $sqlViewport";
    			$link = mysql_query($sql,$cn);
    			$num = mysql_num_rows($link);
    			
    			if($num>0)
    			{
    				while($data=mysql_fetch_row($link))
    				{		
    					$left = ($data[2]-1)*$GRID_WIDTH;
    					$top = ($data[3]-1)*$GRID_HEIGHT;
    					$width=( ( $data[4] ) - ( $data[2] ) + 1)*$GRID_WIDTH;
    					$height=( ($data[5]) - ($data[3]) +1)*$GRID_HEIGHT;
    					
    					//---------------------------------------//
    					//	$width = $width - 2;
    					//	$height = $height - 2;
    					//---------------------------------------//
    					
    					
    					$ext = explode("." , $data[7]);
    					$image_name = "upload_img/" . $data[0] . "." . $ext[1];
    					$tip = get_magic_quotes_runtime() ? htmlentities($data[6]) : addslashes(htmlentities($data[6]));
    					$tip = "<div style=\\'width:150\\'>". $tip ."</div>";
    					
    					echo "<a target=\"_new\" href=\"index.php?id=$data[0]\">
    PHP:
    I believe it needs to be something similar to the following but without the increments in the arrays (this displays the links in a list format and I need them to simply be reflected when some clicks on an image on the site):

    	
    
    $link_g = mysql_query("SELECT url, title FROM links WHERE `active` = 'Yes' ORDER BY id ASC");
    	$i = 0;
    	$links = array();
    	while (($tmp_g = mysql_fetch_array($link_g))) {
    		$links[$i] = $tmp_g;
    		$i++;
      	}
    
    $i = 0;
    foreach ($links as $link) {
    
    	$linkurl = "http://".$link['url'];
    	if ($i == 0) {
    		echo "<tr>";
    	}
    	++$i;
    
    	echo "<td valign='middle' align='left' width='100%' style='padding: 0px;'>";
    	echo "<a href='".$linkurl."' class='contentlink'>".$link['title']."</a>";
    
    
    	if ($i == 1) {
    		echo "</tr>";
    		$i = 0;
    	}
    
    }
    
    
    PHP:
    Any ideas?

    I'm at the end of my rope and figured this would be 5 times easier for the geniuses here on DP! :)
     
    dlow123, Feb 5, 2007 IP
  2. bizoppz

    bizoppz Peon

    Messages:
    1,889
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I would have to see the entire php file to be certain, but it seems that it would simply be a matter of just changing:

    This:
    echo "<a target=\"_new\" href=\"index.php?id=$data[0]\">

    To This:
    echo "<a target=\"_new\" href=\"$data[1]\">
     
    bizoppz, Feb 6, 2007 IP
  3. dlow123

    dlow123 Active Member

    Messages:
    270
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    73
    #3

    Thanks for the reply bizoppz. It actually turned out to be as easy as this:

    adding the following lines:

    $url = stripslashes($data[1]);
    $title = stripslashes($data[6]);

    right before:

    echo "<a target=\"_new\" href=\"index.php?id=$data[0]\">

    then changing:

    echo "<a target=\"_new\" href=\"index.php?id=$data[0]\">

    to:

    echo "<a target=\"_new\" title=\"$title\" href=\"$url\">


    Thanks again and I hope this quick fix helps anyone else out there looking to display static links as opposed to dynamic links. WARNING: This script that I am using counts clicks using the code as it is setup, but the quick dirty fix I made removed that functionality (which in my opinion is not so bad as I would prefer to have the seo advantage).
     
    dlow123, Feb 6, 2007 IP