:-/
my html form consists of drop down for selecting city and state.
radio buttons for selecting gender.
and a few check boxes.

the form is filled and the values are stored in a database table.

I am working on a php script, which retrieves values from database into an array.

consider that my array's first element corresponds to a radio button with value M ( M- male)

then i want the radio button for male to be selected.

similarly if a particular city is selected the i want that city selected in the drop down menu...

this is similar to web sites to which we are registered allow us to update our profiles by displaying the fields with the old values....

your response will be of great help to me...
thanking you guys in advance!!
:)


.

Recommended Answers

All 2 Replies

Member Avatar for TechySafi

post your code...thats easier to understand.

Create a recordset pulling the data from the database. Then, "hook up" the drop down or whatever to the data. Here is an example for a dropdown in php:

<select name="state" id="state">
                      <option value="">-- Select A State --</option>
                      <?php
do {  
?>
                      <option value="<?php echo $row_states['state_name']?>"><?php echo $row_states['state_name']?></option>
                      <?php
} while ($row_states = mysql_fetch_assoc($states));
  $rows = mysql_num_rows($states);
  if($rows > 0) {
      mysql_data_seek($states, 0);
	  $row_states = mysql_fetch_assoc($states);
  }
?>
                    </select>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.