I have tried all I can think of but yet cannot figure out why I my form value is not posting the right value.
Here is the code:
$conn = connect();
$flags = Getflags();
$category = Getcategories();
$newitem = GetNewItems();
[COLOR="red"]//This passes the value to the display.php just fine but it is the wrong value.[/COLOR]
$cid = $_POST['xcid'];
[COLOR="Red"]//Here is the function I am having problems with. I am pulling out the right records and the right values. Yet when I use the onclick submit that I set up using the image I get the ID value of the last record in the mysql database instead of the ID value for the record..[/COLOR]
function Getflags()
{
$res = sql_select_country();
$flags = '<form action="display.php" method="post"><table>';
while($resultset = @mysql_fetch_array($res))
{
$id = $resultset['id'];
$country=$resultset['country_name'];
$flag=$resultset['flag_image'];
$flags .='
<tr>
[COLOR="red"]///This is the value I need to have fixed the hidden field[/COLOR]
<td><input type="hidden" name="xcid" value="'.$id.'" />'. $country .'</td>
<td><input type="image" src="'. $flag .'" onclick="javascript:this.form.submit()"/></td>
<td></td>
</tr> ';
$i += 1;
}
$flags .=' </table></form>';
mysql_free_result($res);
return $flags;
}
//select categories to edit or delete
function Getcategories()
{
$category = '<form action="display.php" method="post"><table>';
global $conn;
$sql="SELECT ID, category FROM category";
$res=mysql_query($sql, $conn);
while ($resultset = @mysql_fetch_array($res))
{
$category .= ($resultset['id']);
$category .= '<tr>
<td><input type="submit" value="' . $resultset['category'] . '" /></td>
</tr>';
$i += 1;
}
$category .= '</table></form>';
mysql_free_result($res);
return $category;
}
[COLOR="red"]//Display.php code[/COLOR]
$conn = connect();
$var = $_GET['xcid']; [COLOR="red"]///Shows the value of the last record only??? So confused[/COLOR]
$content = $var;
If anybody can help me see where I am going wrong I am so close yet so far!!!! Help!!!
Thank you