Getting data from a table by radio buttons???
Posted: Fri Dec 17, 2004 4:10 pm
i want to create a function which will take the line in a table which i have selected by a radio button then i want to take that row out of the table and modify its stock_level with a new value. I know how to modify the stock value. What i don't know how to do and am hoping you guys can help is fetching the row i want out of the table by a radio button and then replacing the value of qty with the new value. I know a long way to do it but is there a quicker way? code from my function is:
Code: Select all
<? function updatestockform()
{
$link_id = db_connect();
$query = "select cat_no, title, artist_id, stock_level from vinyls";
$result = mysql_query($query, $link_id) or die(mysql_error());
if(!result)
{
echo 'No Stock Returned.';
exit;
}else
$list ="<center><table border="1" cellpadding="2" bgcolor="#7b9815" bordercolor="#d2e982">";
$list.="<form align="center" name="updatestockform" method="post" action="stock.php?action=updatestock">";
$list.="<tr><th><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Catalogue Number</div></font></th>";
$list.="<th><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Title</div></font></th>";
$list.="<th><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Artist</div></font></th>";
$list.="<th><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Qty</div></font></th>";
$list.="<th><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Add</div></font></th></tr></div></font>";
while($row = mysql_fetch_array($result))
{
$list.= "<tr>";
$list.= "<td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">".$row["cat_no"]."</div></font></td>";
$list.= "<td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">".$row["title"]."</div></font></td>";
$list.= "<td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">".$row["artist_id"]."</div></font></td>";
$list.= "<td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">".$row["stock_level"]."</div></font></td>";
$list.= "<td width="10"><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><input name="qty" type= "text" maxlength="3" id="qty"></div></font></td>";
$list.= "<td><input name="qtyselected" type="radio"></td>";
$list.= "<td><input type="submit" value="Update"></td>";
}
$list.= "</table></center>";
echo($list);
} ?>