Hi Guys..
I’m new to this forum, and have a question for you.
I have an aplication, similar to a shopping cart, where the user searches for a product, the mysql_query brings back a list of items, as you would expect and they should be able to select an item and move the item onto the next page. All seems ok, in that, when I hover over the selected item, it displays the correct ‘id’ link at bottom, and when I click to go to the next page, it displays the correct id number in the URL at the top, but when I try to echo the details on the page, it displays the LAST item in the array, and not the one I selected??
here is my query to give you an idea of what I mean..
[code=php]<?php
$query = mysql_query(“SELECT *
FROM full_details
WHERE from_town =’$fromPort’ AND to_town =’$toTown'”);
echo “<h2>Results</h2><p>”;
echo “Going from: ” . $_SESSION[‘fromPort’] . ” – Going To: ” . $_SESSION[‘toTown’] . “<br>”;
//Display the results from $search
while($result=mysql_fetch_array($query)){
?>
<table width=”550″ height=”91″ border=”1″ align=”right” background=”images/resultsBG.png”>
<tr>
<td width=”150″ rowspan=”2″>
<img src=”show_image.php?id=<?php echo $result[“id”]; ?>” />
</td>
<td width=”436″ height=”31″><h3><?php $_SESSION[“id”] = $result[“id”]; echo $_SESSION[“id”] . “ ” . $result[“vehicle”]; ?></h3></td>
<td width=”100″><h3><?php echo $result[“cost”] ?></h3></td>
</tr>
<tr>
<td colspan=”2″><?php echo $result[“description”]?>
<table width=”25″ border=”0″ align=”right” height=”25″>
<tr>
<td><a href=”payments3.php?id=<?php echo $_SESSION[“id”]; ?>”><img src=”images/buttonBG.png” width=”25″ height=”25″ /></a></td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
//This counts the number or results – and if there wasn’t any it gives them a little message explaining that
$anymatches=mysql_num_rows($query);
if ($anymatches == 0) {
echo “Sorry, but we can not find an entry to match your query<br><br>”;
}
?>