FW-Mike
06-24-2003, 03:29 AM
I've got a table in my db called addons which has rows added in an admin area. ATM it looks basically like:
id oid name price
1 2 Domain Name 14.99
2 2 5 GB Bandwidth 4.99
I want to be able to echo out all the rows from that table and have checkboxes so that the user can select which ones they want then I want to register the ones they checked in a session so I can call it up later. What I have now doesn't work, I don't care if your fix corrects mine or does it completely different. Any help appreciated!
if(ISSET($_POST["addsub"]))
{
$i = 0;
foreach($_POST['add'] as $key => $v)
{
$i = $i++;
$addon[$i] = $key;
session_register("addon[$i]");
}
print_r ($_SESSION);
}
$result = mysql_query("SELECT * FROM addons WHERE oid='$opid' ORDER BY id ASC") or die("addons ".mysql_error());
if(mysql_num_rows($result) > 0)
{
while ($add = mysql_fetch_object($result))
{
echo "<tr><td colspan='2'><input type='checkbox' name='add[$add->id]'>";
echo "$add->name ($".$add->price.")";
echo"</td></tr>";
}
Even if i check both boxes, print_r ($_SESSION); just shows
Array ( [addon[0]] => )
Thanks in advance
id oid name price
1 2 Domain Name 14.99
2 2 5 GB Bandwidth 4.99
I want to be able to echo out all the rows from that table and have checkboxes so that the user can select which ones they want then I want to register the ones they checked in a session so I can call it up later. What I have now doesn't work, I don't care if your fix corrects mine or does it completely different. Any help appreciated!
if(ISSET($_POST["addsub"]))
{
$i = 0;
foreach($_POST['add'] as $key => $v)
{
$i = $i++;
$addon[$i] = $key;
session_register("addon[$i]");
}
print_r ($_SESSION);
}
$result = mysql_query("SELECT * FROM addons WHERE oid='$opid' ORDER BY id ASC") or die("addons ".mysql_error());
if(mysql_num_rows($result) > 0)
{
while ($add = mysql_fetch_object($result))
{
echo "<tr><td colspan='2'><input type='checkbox' name='add[$add->id]'>";
echo "$add->name ($".$add->price.")";
echo"</td></tr>";
}
Even if i check both boxes, print_r ($_SESSION); just shows
Array ( [addon[0]] => )
Thanks in advance
