Results 1 to 2 of 2

Thread: Checkbox checked (associated tables) - editing with PHP mySQL

  1. #1
    Join Date
    Sep 2012

    Checkbox checked (associated tables) - editing with PHP mySQL

    Hello guys

    I have a small problem and please help to resolve this.
    I have associated categories in the database. During the edit, i need, that
    categories which were checked when first somebody added his/her info that categories to be selected...

    In my picture is described what i want to do.


    Thanks for advice...

    And here is my code
    PHP Code:
    include ("db.php");
    if (isset(
    $_GET['id'])) {$id $_GET['id'];}

    if (!isset(
    $result mysql_query("SELECT id, name, sur FROM info");      
    $myrow mysql_fetch_array($result);
    printf ("<p style='float:left; margin-left:6px;'> &nbsp;<a href='edit.php?id=%s'>%s</a>&nbsp;&nbsp;|</p>",$myrow["id"],$myrow["name"]);
    while (
    $myrow mysql_fetch_array($result));
    $result2 mysql_query("SELECT * FROM info WHERE id=$id");      
    $myrow2 mysql_fetch_array($result2);

    $sql "SELECT cat_id, cat_name FROM category";
    $res mysql_query($sql) or die(mysql_error());
    $checkboxes '';
    while (list(
    $id$cat) = mysql_fetch_row($res)) {
    $checkboxes .= "<input type='checkbox' name='category[]' value='$id' /> $cat<br />";

    print <<<HERE

    <form method = 'post' action = 'update.php' >
        Name: <input type='text' name='name' value="
    $myrow2[name]" size='50' /><br />
        Surname: <input type='text' name='sur' value="
    $myrow2[sur]" size='50' /><br />
        Categories:<br />
        <input type='submit' name='btnSubmit' value='Submit' />


  2. #2
    Join Date
    Jan 2004
    you may want to look up php form handeling checkbox

    then you'll need to need to add to you link table with an : insert
    Natdrip :P
    "water go down the hole" - plucky duck

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles