Help.....displaying variable in HREF

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
polosport6699
Forum Commoner
Posts: 35
Joined: Wed Jun 11, 2003 3:19 pm

Help.....displaying variable in HREF

Post by polosport6699 »

I have this code printed out with alternating rows, and I cannot get the code to display the varible $jcode in the html <a href=?cmd=$jcode> to display an automatic link. Jcode is the unique mysql identifyer key

Code: Select all

$query = "SELECT jcode, designation, responsibilities, city, posted FROM listing WHERE listing.status = 'yes' ORDER BY $order_by";
$result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query1. " . mysql_error());
list($jcode) = mysql_fetch_row($result);
if(mysql_num_rows($result)) {
  $rank = 1;
  while($row = mysql_fetch_row($result)) 
  {
    print("</tr><tr>");
    if($color == "#FFFFFF") {
     $color = "#DFDFDF";
    } else {
      $color = "#FFFFFF";
    }

   print("<td width="5px" bgcolor="$color"><center><small>");
   print("<font face="Verdana">$rank</font></small></center></td>");
   print("<td width="75px" bgcolor="$color"><left><small>");
   print("<font face="Verdana"><a href=?cmd=$jcode>$row[1]</font></a></small></center></td>");
   print("<td width="235px" bgcolor="$color"><small>");
   print("<font face="Verdana">$row[2]</font></small></center></td>");
   print("<td width="75px" bgcolor="$color"><left><small>");
   print("<font face="Verdana">$row[3]</font></small></left></td>");
   print("<td width="85px" bgcolor="$color"><left><small>");
   print("<font face="Verdana">$row[4]</font></small></left></td>");
  $rank++;
			}
		}
}
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Are you sure $jcode contains what you think it does? After you do list($jcode), do a var_dump($jcode); and see if it's the value you think it should be.
Post Reply