Checkboxes and lists requie you to set the checked / selected property.
So you would need to do something like (In Pseudocode):
if (thisCheckBoxValueFromDatabase == Selected){
echo "<input type=\"checkbox\" checked name=\"theName\">\n";
}else{
echo "<input type=\"checkbox\" name=\"theName\">\n";
}
The same applies for your Selection boxes, only u set the <option
selected>Blah</option> for selected and <option>Blah</option> for
unselected.
- Ali
"Xerxes" <ashkan57hotmail.com> wrote in message
news:91970219665e37b1995bc9f1086fc9f8news.teranew s.com...the> Hi,
> I am trying to set up some form fields based on values queried from a
> database, in a PHP file.
> If users have already filled out a form and have an ID, they can enter the
> ID and have the form filled automaticaaly based on results fetched fromor> DB (using customer id).
> I put the <input ...> field where users enter their id in one form that
> submits to itself and the actual form field (FirstName, LastName,...) in a
> separate form. There is no problem, I can enter the id and get the results
> from DB and have the fields filled in. The problem is that I can only fill
> in the <inpt...> fields and don't know how to get the checkboxes checked$FirstName> Select boxes show the proper text(option).
> // $cid is customer id that user enters, using an input field called cid
> $cid = $_POST['cid'];
> $query = "SELECT * from Customers WHERE CustomerID=\"$cid\"";
> $result = mysql_query($query);
> if(mysql_numrows($result)>0)
> {
> $result = mysql_fetch_array($result);
> $FirstName = $result['FirstName'];
> $LastName = $result['LastName'];
> ....
> $select_field = $result['value_from_a_select_box'] // Let's say = text2
> $checked_value = $result['value_based_on_a_checkbox_] // if == "yes",
> check the checkbox
> }
>
> Then in form:
> <input type="text" name="FirstName" size="30" value="<?php echo> ?>" />
> <select name="select_name">
> <option>text1
> <option>text2
> <option>text3
> </select>
>
> <input name="FR" type="checkbox">
>
> I really appreciate your help.
>
> TIA.
>
>
Bookmarks