Call php function from radio button click
I am creating two sets of three radio buttons (small, medium, large) and (red, green, blue) plus a function to display the item id number so when a radio button is clicked an item id number for that combination of sizes/colors is shown.
The code to display the item id is in function showid() as seen below:
QUESTION
How do I get it so that function showid() is called when a radio button is clicked?
I am creating two sets of three radio buttons (small, medium, large) and (red, green, blue) plus a function to display the item id number so when a radio button is clicked an item id number for that combination of sizes/colors is shown.
The code to display the item id is in function showid() as seen below:
QUESTION
How do I get it so that function showid() is called when a radio button is clicked?
Code:
<table>
<tr>
<form>
<td>
<?
include("testdb.php");
MYSQL_CONNECT(HOST,USER,PASS) OR DIE("Unable to connect to database");
@mysql_select_db(DB) or die( "Unable to select database");
$query=("select * from categories order by color desc");
$result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() );
$selectedflag1= 1;
while($row=mysql_fetch_array($result)){
$color = @$row["color"];
if ($selectedflag1== 1){
$selected1 = "checked";}
else{
$selected1 = "";
}
echo " <input type=\"radio\" name=\"color\" value=\"$color\" $selected1 >$color";
echo "<br>";
$selectedflag1 = 2;
}
?>
</td>
<td>
<?
$query=("select * from categories order by size desc");
$result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() );
$selectedflag2= 1;
while($row=mysql_fetch_array($result)){
$size = @$row["size"];
if ($selectedflag2== 1){
$selected2 = "checked";}
else{
$selected2 = "";
}
echo " <input type=\"radio\" name=\"size\" value=\"$size\" $selected2 >$size";
echo "<br>";
$selectedflag2= 2;
}
?>
</td>
<td>
<?
function showid(){
$query=("select itemID from inventory WHERE itemColor = '$color' AND itemSize = '$size'");
$result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() );
$querydata = mysql_fetch_array($result);
$theitemID = $querydata["itemID"];
echo("$theitemID");
}
?>
</td>
</form>
</tr>
</table>