A href link with 'id'

Hello Guys,

I am a newbie and have spent many hours searching on the net but have not been able to do it.

I am trying to create a link with a thumbnail image on (summary.php page). When the link is clicked, I want a new page (say detail.php) to open. However, the link is supposed to reveal more pictures and information. All the information sit on one table in the same database and I want a link from the summary.php page to reveal all the information on that same record on the other page (detail.php page). I do not know how to transfer the “id” to the detail page in order to specify in a query to reveal the whole information on the clicked image link.

Below is the query to display information on the summary page.

summary.php page

$sql = mysql_query(“SELECT * FROM classified”);
while($row = mysql_fetch_array($sql)){
echo “<table border = ‘1’>”;
echo “<tr>”;
$id = $row[‘id’];
echo “<td rowspan = ‘3’>” . ‘<a href = “details.php?id = $id” . “>”’ . “<img src ='” . $row[‘photo1small’] .“'” . “/>” . “</a>”. “</td>”;
echo “<td width = ‘300’>”. $row[‘title’] . “</td>”;
echo “<td width = ‘100’>”. $row[‘price’] . “</td>”;
echo “</tr>”;
echo “</table>”;
echo “<br/>”;
}

detail.php page

<?php
$id = $_GET[‘id’];
echo $id;

?>

Parse error: syntax error, unexpected ‘"’, expecting ‘,’ or ‘;’ in C:\wamp\www\showclassified.php on line 11

I keep getting errors like the one above and I would appreciate if someone could help me with this.

Thank you

Kofifred

This code:

$id = 15;
$row['photo1small'] = 'photo1small';

echo "<td rowspan = '3'>" . '<a href = "details.php?id = $id" . ">"' . "<img src ='" . $row['photo1small'] ."'" . "/>" . "</a>". "</td>";

produces this output:

<td rowspan = '3'><a href = "details.php?id = $id" . ">"<img src ='photo1small'/></a></td>

As you can see there are too many spaces that should not be there
The $id variable didn’t behave as a variable
There is a dot and double quotes that should not be there

You’re better off using a different way to write that string:

$id = 15;
$row['photo1small'] = 'photo1small';

echo "<td rowspan='3'><a href='details.php?id={$id}'><img src='{$row['photo1small']}'/></a></td>";

and then you get

<td rowspan='3'><a href='details.php?id=15'><img src='photo1small'/></a></td>

Thank you. It worked. You have saved me a lot.