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>
<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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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</opti on>";
}
else
{
print "<option value=\"A\">Adult</option> ";
}
if($dogtype == "P")
{
print "<option value=\"P\" selected=\"P\">Puppy</opti on>";
}
else
{
print "<option value=\"P\">Puppy</option> ";
}
?>
</select>
</p>
<p><strong>Dog Type</strong>
<select name="fdogtype">
<?
if($dogtype == "A")
{
print "<option value=\"A\" selected=\"A\">Adult</opti
}
else
{
print "<option value=\"A\">Adult</option>
}
if($dogtype == "P")
{
print "<option value=\"P\" selected=\"P\">Puppy</opti
}
else
{
print "<option value=\"P\">Puppy</option>
}
?>
</select>
</p>
ASKER
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.
Accepted answer: 0 points for StarThunder's comment #a39504816
for the following reason:
I came up with the solution on my own.
ASKER
{
$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"
<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".