#1
  1. No Profile Picture
    Barn
    Guest
    Devshed Newbie (0 - 499 posts)
    I have a PHP-MySQL setup, where people can register them selves to a database, this involves some checkboxes. Thing is when people later wants to edit their data, they are presented with a form, where their current information is allready filled in, ready to be edited, -BUT NOT THE CHECKBOXES!!
    All the textboxes works fine, there I set the value attribute to the corresponding value in the database. The point is: when I have a value of true/yes, (as opposed to false/no) in the database, I want the checkboxes in the form to be checked. How do I do this? When the forms are used for outputting data, the state of the checkbox is not related to the value of the checkbox, this is only true for input of data.
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    you can pass the database value to a check box like this:

    <?php

    echo "<input type="checkbox" name="C1" value="yes"";

    if( $row["check_val"]=="yes"){
    # if database field value =yes then
    echo "checked";
    }
    echo ">";

    ?>



    ------------------
    SR -
    shiju.dreamcenter.net

    "The fear of the LORD is the beginning of knowledge..."



    [This message has been edited by Shiju Rajan (edited May 30, 2000).]
  4. #3
  5. No Profile Picture
    Barn
    Guest
    Devshed Newbie (0 - 499 posts)
    I must say, the answer is SO SIMPLE, I could kick myself. No wonder I was unable to figure it out myself... Thanks a lot for the extremly quick and useable answer.

Similar Threads

  1. passing javascript to a php generated form
    By jhedstrom in forum JavaScript Development
    Replies: 8
    Last Post: August 25th, 2005, 10:08 PM
  2. passing back password fields to form without showing them?
    By ralphuk100 in forum PHP Development
    Replies: 8
    Last Post: February 6th, 2004, 12:00 PM
  3. HTTP Error 400: Bad Request, with basic form
    By crackwombat in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 07:40 PM
  4. Passing objects into Smarty
    By rlorenzo in forum PHP Development
    Replies: 1
    Last Post: January 13th, 2004, 12:22 PM
  5. Passing values from form to php page
    By giftsandwicks in forum PHP Development
    Replies: 3
    Last Post: December 19th, 2003, 02:07 AM

IMN logo majestic logo threadwatch logo seochat tools logo