hi everyone
i am getting a bunch of values from a form via post all of the information that this question deals with is from series of check boxes below is the code that creates the check boxes
the logic behind it is it gets a bunch of listing from the database and if $group is not null then the first check box is checked and a second created else only one unchecked checkbox is created
[PHP]
$result=mysql_q uery("SELECT TITLE, FNMI, LN, COMPANY, E_MAIL, id, $group FROM DBASE ORDER BY LN");
while($row = mysql_fetch_row ($result))
{
if ($row[4] != NULL)
{
if($row[6] != NULL)
{
echo "<input type='checkbox' name='$row[5]' value='$row[5]' checked='checke d'>";
echo $row[2], ", ", $row[1], "<input type='checkbox' name='del", $row[5], "' value='$row[5]'><br>\n";
}else{
echo "<input type='checkbox' name='$row[5]' value='$row[5]'>";
echo $row[2], ", ", $row[1], "<br>\n";
}
}
}
[/PHP]
this then goes to the processing script
here i send the $_POST array through a foreach loop getting both the key and the value stored into variables
then i make sure the value is_numeric
then i explode the key to get the 'del' off and store it into the delete array
next i have a sql select statement followed by a loop that walks through all rows of the select
when i am in this loop my $delete array is non existent i've printed it out right below where i make it and it is fine i've even assigned $delete[1] which holds the value i need to a variable and printed that out and it works before the loop but in the loop those variables don't seem to exits
below is that code
[PHP]
foreach($_POST as $key => $value)
{
if(is_numeric($ value))
{
$delete = explode("del", $key);
$del = $delete[1];
echo $del;//it is displayed here
$result = mysql_query("SE LECT id, $new FROM DBASE WHERE id = $key OR $new IS NOT NULL");
while ($row = mysql_fetch_row ($result))
{
if ($row[0] == $key)
{
if ($row[1] == NULL)
{
mysql_query("UP DATE `DBASE` SET `$new` = 'X' WHERE `id` = $key LIMIT 1");
}
}
echo $del; //but not here
if ($row[0] == $del)
{
mysql_query("UP DATE `DBASE` SET `$new` = NULL WHERE `id` = $row[0] LIMIT 1");
}
}
}
}
[/PHP]
for the values where there were two check boxes the values are the same one of the keys has a 'del' in front of it the problem i seem to be having is when i explode the 'del' off the key
i am getting a bunch of values from a form via post all of the information that this question deals with is from series of check boxes below is the code that creates the check boxes
the logic behind it is it gets a bunch of listing from the database and if $group is not null then the first check box is checked and a second created else only one unchecked checkbox is created
[PHP]
$result=mysql_q uery("SELECT TITLE, FNMI, LN, COMPANY, E_MAIL, id, $group FROM DBASE ORDER BY LN");
while($row = mysql_fetch_row ($result))
{
if ($row[4] != NULL)
{
if($row[6] != NULL)
{
echo "<input type='checkbox' name='$row[5]' value='$row[5]' checked='checke d'>";
echo $row[2], ", ", $row[1], "<input type='checkbox' name='del", $row[5], "' value='$row[5]'><br>\n";
}else{
echo "<input type='checkbox' name='$row[5]' value='$row[5]'>";
echo $row[2], ", ", $row[1], "<br>\n";
}
}
}
[/PHP]
this then goes to the processing script
here i send the $_POST array through a foreach loop getting both the key and the value stored into variables
then i make sure the value is_numeric
then i explode the key to get the 'del' off and store it into the delete array
next i have a sql select statement followed by a loop that walks through all rows of the select
when i am in this loop my $delete array is non existent i've printed it out right below where i make it and it is fine i've even assigned $delete[1] which holds the value i need to a variable and printed that out and it works before the loop but in the loop those variables don't seem to exits
below is that code
[PHP]
foreach($_POST as $key => $value)
{
if(is_numeric($ value))
{
$delete = explode("del", $key);
$del = $delete[1];
echo $del;//it is displayed here
$result = mysql_query("SE LECT id, $new FROM DBASE WHERE id = $key OR $new IS NOT NULL");
while ($row = mysql_fetch_row ($result))
{
if ($row[0] == $key)
{
if ($row[1] == NULL)
{
mysql_query("UP DATE `DBASE` SET `$new` = 'X' WHERE `id` = $key LIMIT 1");
}
}
echo $del; //but not here
if ($row[0] == $del)
{
mysql_query("UP DATE `DBASE` SET `$new` = NULL WHERE `id` = $row[0] LIMIT 1");
}
}
}
}
[/PHP]
for the values where there were two check boxes the values are the same one of the keys has a 'del' in front of it the problem i seem to be having is when i explode the 'del' off the key
Comment