Author Topic: link to detailed page  (Read 126 times)

Jennifer

  • Guest
link to detailed page
« on: February 02, 2012, 03:31:42 PM »
I am working on a product inventory website in which i want to show a list of a certain type of product and then provide a link to more detailed information regarding a specific product.
However, I can't get the individual link to work, it keeps shutting down the whole page.

PHP Code: [Select]
<?php 
	
$query mysql_query("SELECT * FROM presses WHERE `type` = 'upsetter'");
	

	

	
echo 
"<table border='1' id='presses' class='presses'>
	
	
<tr>
	
	

	
	
</tr>"
;
	
while(
$row mysql_fetch_array($query))
   {
 
	
echo 
"<tr>";
  
	
echo 
"<td>" $row['name']. "[b] <a href="profile.php?id=$row['id']">View Press Details</a></td>";[/b]
   
	
echo 
"<td> <img src=" $row['image']. " /> </td>";
   
	
echo 
"<td> <a href="profile.php?id=$id">View Press Profile</a> </td>"
  
	
echo 
"</tr>";
  }
echo 
"</table>";
mysql_close($connection);

 
?>


the bold is the line I am having issues with. I have tried making it its own cell, its own paragraph. Nothing seems to work. Any help would be appreciated.

Thanks!

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: link to detailed page
« Reply #1 on: February 03, 2012, 02:12:03 PM »
From what I see in your code, you need to concatenate closing </td> at the end, just like you did in the beggining

SO:

PHP Code: [Select]
echo "<td>" $row['name']. "[b] <a href="profile.php?id=$row['id']">View Press Details</a></td>";[/b]

SHOULD BE:

PHP Code: [Select]
	


echo 
"<td>" $row['name']. "<a href="profile.php?id=$row['id']">View Press Details</a>[/b]" "</td>"  ;


Try that to see if it helps.

Another thing, when posting in this forum, you can't bold stuff inside the "php code insertion tags" ebcause it is just going to display it as part of the code and it might throw some people off when trying to help.

« Last Edit: February 03, 2012, 02:41:47 PM by jj-dr »

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: link to detailed page
« Reply #2 on: February 03, 2012, 03:30:42 PM »
OK, I spotted the main issue with your code. It's inconsistent concatenation.

PHP Code: [Select]
echo "<td>" $row['name']. "[b] <a href="profile.php?id=$row['id']">View Press Details</a></td>";
[/
b]


SHOULD NOW BE:
PHP Code: [Select]
echo  "<td>".$row['name']. "<a href='profile.php?id=.'".$row["id"]." '>View Press Details</a>" ."</td>";

The problem resides in your  <a href> code, more specifically, <a href="profile.php?id=$row['id']"> needs to be adjusted like this:
"<a href='profile.php?id=.'".$row["id"]." '>

You cannot have same same type quote marks sequencially without concatenation as you did here:
"<a href="profile.php?id=$row['id']">, plus you needed to concatenated $row id since is a variable.
« Last Edit: February 03, 2012, 03:33:41 PM by jj-dr »