I'm a newbie in PHP and i've got stucked into this...
I have a database and a simple search form. I can search without problems using the criteria i want - for example, i fill in as name "Alex" and i can see 5 records in my resultset with this criteria. So far so good...
Here's the problem : I need to create a Link / Button - whatever - and Post/Get the values for the specific record that i'll choose. When the resultset contains only one record found, i have no problems - everything works fine. But, whenever the resultset returns more than 1 records, the Post/Get method grabs the data for the last record.
Let me show you what i'm doing here... Here's the data i'm retrieving :
while ($row= mysql_fetch_array($result)) {
$my_id = $row["ID"];
$my_name = $row["name"];
$my_profession = $row["profession"];
echo "<div align='center'><tr>
<td><div align='center' style='color:white;'><font size='2' face='Arial'>$my_id</div></td></font>
<td><div align='center' style='color:white;'><font size='2' face='Arial'>$my_name</div></td></font>
<td><div align='center' style='color:white;'><font size='2' face='Arial'>$my_profession</div></td></font>
<td><div align='center' style='color:white;'><font size='2' face='Arial'><form action='person_info.php' method='POST'><input type='hidden' name='PersonID' value='$my_id' /><input type='hidden' name='PersonName' value='$my_name' /><input type='hidden' name='PersonProfession' value='$my_profession' /><input type='submit' value='Show' /></div></td></font>
.....
Here's the code for person_info.php :
$my_id = $_POST["PersonID"];
$my_name = $_POST["PersonName"];
$my_profession = $_POST["PersonProfession"];
echo "
<div align='center'><font size='4' face='Georgia' style='color:red';><b>$my_id, $my_name, $my_profession</b></font></div>
If there's only one record involved, everything works great. If there's more than one, i get the last one's details. For example, from the resultset :
1 Alex Unemployed 2 Alex Carpenter 3 Alex Gardener
... the record that will be posted finally is the "3 Alex Gardener".
Any ideas ?
Thanks in advance!