I'm hoping someone can help, as I am having trouble getting checkboxes to work properly. I have 5 checkboxes so far in a field called "options", and I am using one page to add the data, a second to verify what was just entered, and the third to display the entire record.
What happens is the verification page is fine, but on the final record output page, ALL the "options" are printed, although they were not all checked off.
Here are the parts of the code, and I would appreciate your help and "input"!
Thank you!
HERE IS THE FORM:
add.php3
...
<P><STRONG>Options:</STRONG><BR>
<INPUT TYPE="checkbox" NAME="options[]" VALUE="Power Steering">Power Steering<br>
<INPUT TYPE="checkbox" NAME="options[]" VALUE="Power Brakes">Power Brakes<br>
<INPUT TYPE="checkbox" NAME="options[]" VALUE="Power Windows">Power Windows<br>
<INPUT TYPE="checkbox" NAME="options[]" VALUE="Power Locks">Power Locks<br>
<INPUT TYPE="checkbox" NAME="options[]" VALUE="Air Conditioning">Air Conditioning<br>
...
</P>
HERE IS THE VERIFICATION PAGE:
verifyadd.php3
$sql = "INSERT INTO $table_name
(id, stock, year, make, model, vin, milage, color, engine, trans, options, description, price, photoname)
VALUES
(\"\",
\"$stock\", \"$year\", \"$make\", \"$model\", \"$vin\", \"$milage\", \"$color\", \"$engine\", \"$trans\", \"$options\", \"$description\", \"$price\", \"$photoname\")
";
$result = @($sql,$connection) or die("Couldn't execute query.");
...
<P><STRONG>Options:</STRONG><BR>
<ul>
<?
$count=count($options);
for ($x = 0; $x < count($options); $x++)
{
print "<li>$options[$x]</li>";
}
?>
</ul>
</P>
THE FINAL RECORD OUTPUT PAGE:
record.php3
...
f ($chk_id_num == "0") {
header("Location: http://localhost/panel.php3");
exit;
} else {
$sql = "SELECT stock, year, make, model, vin, milage, color, engine, trans, options, description, price, photoname
FROM $table_name
WHERE id = \"$id\"
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");
while ($row = mysql_fetch_array($result)) {
$stock = $row['stock'];
$year = $row['year'];
$make = $row['make'];
$model = $row['model'];
$vin = $row['vin'];
$milage = $row['milage'];
$color = $row['color'];
$engine = $row['engine'];
$trans = $row['trans'];
$options = $row['options'];
$description = $row['description'];
$price = $row['price'];
$photoname = $row['photoname'];
}
}
...
<ul>
<?
$count=count($options);
for ($x = 0; $x < count($options); $x++)
{
print "<li>$options[$x]</li>";
}
?>
</ul>