dynamic checkbox dilema (how to $_GET dymanic names?!)
Posted: Fri Sep 01, 2006 1:37 am
Hi there, I draw part of my form by taking dynamic info directly from the database. Here is an example:
This works a treat and draws a whole bunch of checkboxes (pre-checked) and when I refresh the form, yes, there are all the names in the url. Here is an example url (trimmed down to only show the checkbox data):
What I want to be able to do is, whilst the form is drawn with above loop, check if the checkbox is ticked or not (so I can uncheck it or check it depending on its status last time through).
Whilst I could setup a whole bunch of $_GET's this won't really get me anywhere as the user can change those group names at will, including deletion or adding of new ones (as many as they'd like).
How can I get around this? I really feel very stuck!!!

All ideas greatly appreciated,
Rob
Code: Select all
//for the GROUPING
//================
mysql_select_db($dbname);
$sql = "SELECT * FROM grouping ORDER BY group_id ASC";
$content = mysql_query($sql);
$Xcontent = mysql_fetch_array($content);
$cShowMax = mysql_num_rows($content);
for ($y=1; $y<=$cShowMax; $y++)
{
$group_id = $Xcontent["group_id"];
$group_name = $Xcontent["group_name"];
$group_type = $Xcontent["group_type"];
echo "<td align = \"center\"><input name=\"$group_name\" type=\"checkbox\" value=\"$group_id\" checked /><br />$group_name</td>";
$Xcontent = mysql_fetch_array($content);
}
mysql_free_result($content);
?>This works a treat and draws a whole bunch of checkboxes (pre-checked) and when I refresh the form, yes, there are all the names in the url. Here is an example url (trimmed down to only show the checkbox data):
Code: Select all
&Hulabaloo=13&Beauty+Products=14&Beauty+Services=15&Beauty+Rent=16&Cutting=17&Colour=18&Training=19&Treatments=20&Makeup=25&Makeup+Service=26Whilst I could setup a whole bunch of $_GET's this won't really get me anywhere as the user can change those group names at will, including deletion or adding of new ones (as many as they'd like).
How can I get around this? I really feel very stuck!!!
All ideas greatly appreciated,
Rob