Thread: checkbox

  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Rep Power
    here's the prob....I query the DB and it pulls up the needed info in table form. I edit the info and want to submit it back to the DB for updating. I have all that done, what I want to do is use a checkbox to where if the checkbox is checked, only that info is submitted to the DB when I hit the submit button. all the info with unchecked boxes will return to the screen for editing. how do I do this?????
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Niagara Falls (On the wrong side of the gorge)
    Rep Power
    A very simple example:

    // assume connected to db (using mysql here)

    $result=mysql_query("select id,name,address,city,state from table");

    <form method=post action=edit.php>
    <tr><td>Click to edit</td>
    for ($i=0;$i<mysql_num_rows($result);$i++)
    <input type=hidden name=id[<? print $i ?>] value='<? print $data[id] ?>'>
    <tr><td><input type=checkbox name=edit[<? print $i ?>]></td>
    <td><input type=text name=name[<? print $i ?>] value='<? print $data[name] ?>'></td>
    <td><input type=text name=address[<? print $i ?>] value='<? print $data[address] ?>'></td>
    <td><input type=text name=city[<? print $i ?>] value='<? print $data[city] ?>'></td>
    <td><input type=text name=state[<? print $i ?>] value='<? print $data[state] ?>'></td>
    <input type=submit name=submit value=Edit>

    Then in edit.php:

    for ($i=0;$i<count($id);$i++)
    if ($edit[$i])
    $query="update table set name='$name[$i]',address='$address[$i]',city='$city[$i]',state='$state[$i]' where id=$id[$i]";

    Happy hacking

Similar Threads

  1. Grayed Out but enabled checkbox
    By thomasdayton123 in forum HTML Programming
    Replies: 0
    Last Post: November 14th, 2003, 10:30 PM
  2. checkbox problem
    By aspkid in forum ASP Programming
    Replies: 9
    Last Post: October 9th, 2003, 01:44 AM
  3. checkbox assistance needed
    By linhardt in forum HTML Programming
    Replies: 6
    Last Post: October 2nd, 2003, 12:19 PM
  4. passing a checkbox array
    By areric in forum PHP Development
    Replies: 2
    Last Post: September 7th, 2003, 01:45 PM
  5. Multiple checkbox entry in database
    By avtar in forum PHP Development
    Replies: 8
    Last Post: November 8th, 2002, 01:00 PM

IMN logo majestic logo threadwatch logo seochat tools logo