Getting data from a table by radio buttons???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mmc01ms
Forum Commoner
Posts: 97
Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK

Getting data from a table by radio buttons???

Post by mmc01ms »

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);
			
		} ?>
Post Reply