Log in

View Full Version : please help me



eamon
07-09-2006, 04:33 PM
i'm posting a form to itself and using the session to store values. the script doesn't insert/update any details to database if the criteria isn't met. that said, i have some check boxes that i can't get to work here is the code.

this goes at the top of the script to set the session and gain the values.

if(isset($_POST['activities'])) {$_SESSION['activities'] = $_POST['activities']; $activities = $_SESSION['activities']; } else { $activities = ""; }

these loops contain the checkboxes retrieving the data back from the database
//Activity checkboxes tag

$acti = mysql_query("select * from activity order by activity");
$html .= "<td style='width:20%'>Activities:</td><td><table style='width:100%' class=login><tr>\n";

$html .= "<td align=\"left\" width=\"25%\" valign=\"top\" >";
for($ok = 1; $ok <= mysql_num_rows($acti);$ok ++)
{
$acy = mysql_fetch_array($acti);
$html .= "<input type=checkbox class=check name=activities[] value=" . $acy[0] . ($activities == $acy[0] ? " checked " : "") . " /> $acy[1]<br>\n";
if($ok===4){break; $html .= "<tr></tr>"; continue;}
}
$html .= "</td>";

$html .= "<td align=\"left\" width=\"25%\" valign=\"top\" >";
for($ok = 5; $ok <= mysql_num_rows($acti);$ok ++)
{
$acy = mysql_fetch_array($acti);
$html .= "<input type=checkbox class=check name=activities[] value=" . $acy[0] . ($activities == $acy[0] ? " checked " : "") . " /> $acy[1]<br>\n";
if($ok===8){break; $html .= "<tr></tr>"; continue;}
}
$html .= "</td>";

$html .= "<td align=\"left\" width=\"25%\" valign=\"top\" >";
for($ok = 9; $ok <= mysql_num_rows($acti);$ok ++)
{
$acy = mysql_fetch_array($acti);
$html .= "<input type=checkbox class=check name=activities[] value=" . $acy[0] . ($activities == $acy[0] ? " checked " : "") . " /> $acy[1]<br>\n";
if($ok===12){break; $html .= "<tr></tr>"; continue;}
}
$html .= "</td>";

$html .= "<td align=\"left\" width=\"25%\" valign=\"top\" >";
for($ok = 13; $ok <= mysql_num_rows($acti);$ok ++)
{
$acy = mysql_fetch_array($acti);
$html .= "<input type=checkbox class=check name=activities[] value=" . $acy[0] . ($activities == $acy[0] ? " checked " : "") . " /> $acy[1]<br>\n";
if($ok===16){break; $html .= "<tr></tr>"; continue;}
}

$html .= "<input type=hidden value=" . mysql_num_rows($acti) . " name=actlimit />\n";
$html .= "</td>";

$html .= "</tr></table></td></tr>\n";

Twey
07-11-2006, 02:20 AM
I don't think [] is allowed in an attribute value without being quoted.

eamon
07-11-2006, 05:51 PM
thanx i'll try that. safe bro