Page 1 of 1

help with checkboxes (multidimensional array) in HTML forms

Posted: Mon Feb 23, 2004 12:09 pm
by lkj
Hi All,

Happy Monday!

I want to show the fields of each table in my DB as checkboxes in a user form that user can check and my program selects the column data from the DB depeneding on checked boxes.

e.g.

Table 1

fields as checkboxes

Table 2

fields as checkboxes

How do I get the info about the checked fields in each of the tables?


I hope it's clear enough.

Thank you all.

lkj

Posted: Mon Feb 23, 2004 4:58 pm
by tim
hi - I assume u know how to connect to the database and pull info from it, so all u need is a loop to display the info in the DB and a form as checkboxes to accomodate the info... simple:

Code: Select all

<?php
$sql = "select * from table_name order by id";
//I assume u have a ID field in your DB so each field has its own idenification key
$result = mysql_query($sql);
$id = $row["id"];
while ($row = mysql_fetch_array($result)) {
echo "<form action=delete.php$delete POST><input type=checkbox name=delete[] value=$id> delete whatever";

//now on delete.php
if(isset($delete)) {
run whatever u want here
}
?>
Now this will display the table and when checked, will send to delete.php (like on mine I have it so I can delete msgs of the checkboxed items displayed in my table.. u can modify the code to whateevr u like

and so u know, delete[] will make the data that is checked into a array so u can pass multiple variiables..

What did u want done with the data in the db anyway? edit them, delete them?