Question before start( rebuilding add form to a Update form )

Hello phpjers

Before i start i want to thank everybody who helped me in previos post, or in general al the helpers…

Now i finisht my form for adding an image file with some text fields and some dropdown fields…

My new task!

  • Make a page to list my data from my data base…
    : and an edit button to edit the product…
  • and rebuild the add product page to a update page…

Now i dont know how i can do the folloing:
on my form to add data, i have a drop down…
now when i submit the page its saving the data in the data base just as tekst,
no drop down ID wil we saved…

  • how can i list request the dropdown field from out of the data base and select as current( and also add the other existing dropdown data from an other table in en the update dropdown…

Hopely somebody,
guide me to start …

Thankx in advance

Just read your text data from the database table and then select corresponding value in your drop down list. Something like this:

$drop_down = ’ Option 1 Option 2’;

if($_REQUEST[‘edit_id’] and !$_POST[‘submit’]){ // if we’re editing record, read data from database to populate form
$r = mysql_query(“select * from MyRecords where id=”.$_REQUEST[‘edit_id’]);
$f = mysql_fetch_array($r);
$sel = $f[‘Option’];
$drop_down = str_replace(‘value="’.$sel.’"’,‘value="’.$sel.’" selected’,$drop_down);
// if not editing - leave form values as is

Option: <?php echo $drop_down ?> [/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service