Link to home
Start Free TrialLog in
Avatar of StarThunder
StarThunder

asked on

php form dropdown won't populate existing data

This is my code, I have a dropdown on a form. I'm working on an EDIT screen. The form loads the proper data, but no matter what I do it won't show the proper data Y or N. This is only one way I've been trying it.

<p><strong>Sold?</strong>
<select name="fsold" value="<? print $sold?>">
      <option value="N">No</option>
      <option value="Y">Yes</option>
</select>
</p>
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of StarThunder
StarThunder

ASKER

while ($row = mysql_fetch_array($query))
{
      $name = $row['Name'];
      $descrption = $row['Description'];
      $price = $row['Price'];
      $dogtype = $row['DogType'];
      $dogsex = $row['DogSex'];
      $sold = $row['sold'];
      $mainpic = $row['MainPic'];
      $pic01 = $row['Pic01'];
      $pic02 = $row['Pic02'];
}
?>


<form method=post action="do_dogfileget.php" ENCTYPE="multipart/form-data">

<p><strong>Dog's Name</strong>
      <input type="text" name=fname size=40 maxlength=40 value="<? print $name?>">
</p>


This is the text before the earlier text. fsold = $sold

What I'm looking for is how to display the value already in the record, like "N".
Thanks for offering help, but I figured it out. Here is the code...

<p><strong>Dog Type</strong>
<select name="fdogtype">
<?
      if($dogtype == "A")
      {
            print "<option value=\"A\" selected=\"A\">Adult</option>";
      }
      else
      {
            print "<option value=\"A\">Adult</option>";
      }
      
      if($dogtype == "P")
      {
            print "<option value=\"P\" selected=\"P\">Puppy</option>";
      }
      else
      {
            print "<option value=\"P\">Puppy</option>";
      }
?>
</select>
</p>
I've requested that this question be closed as follows:

Accepted answer: 0 points for StarThunder's comment #a39504816

for the following reason:

I came up with the solution on my own.