I'm using a while
loop and mysql_fetch_array
to display info on a page from a database. How can I give a variable name to certain radio button elements that are echoed on the page, and then use those variable names for the radio buttons as $_POST
variables when the form is submitted?
Here is the code:
session_start();
include 'acdb.php';
$prodid = $_SESSION['prodid'];
$e = "SELECT * FROM Images WHERE product_id=$prodid AND active='yes'";
$e_result = mysql_query($e,$connection) or die ('Could not get the list of all Images for this Product and Service');
$amount = mysql_num_rows($e_result);
while ($e_data = mysql_fetch_array($e_result)) {
echo "<img src='images/thumbnails/" .$e_data[1]. "' border='0'>";
echo "<label class='sel-photo'>DISPLAY PICTURE:</label> <input type='radio' name='{radio" .$e_data[0]. "}' value='1'>";
echo "<br>";
echo "<label class='sel-photo'>DO NOT DISPLAY PICTURE:</label> <input type='radio' name='{radio" .$e_data[0]. "}' value='0' checked>";
}