Test db value using radio button on a form

I have a form that pulls the value from the 'approved' field in my db ... but I prefer to use a rdio button ... how do I test for the value in the table in order to populate the correct radio button ..

here is the code I attempted:

echo "<td>Yes&nbsp;</td>\n";
echo "<input <?php if ($row['approved'] == 'Yes') {'checked'; } ?> type='radio' name='approved' value='Yes'>&nbsp;No&nbsp;<input <?php if ($row['approved'] == 'No') {'checked; } ?> type="radio" name='approved' value='No'></td>\n";

the error message i get is this:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in E:\options\websites\foalauctiontest\admin\edit_seller.php on line 164

I'm tretty new to php but I understand asp forms and radio buttons .. any help would be greatly appreciated ...

TIA
koochyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TomeeboyCommented:
You need to echo 'checked':

<?php if ($row['approved'] == 'Yes') { echo 'checked'; } ?>
0
koochyAuthor Commented:
that didn't work .. here is the entire form ...

<form action="edit_seller.php?ID=<?php echo $row['sellerID'] ?>" method="post">
<?php
echo "<table cellpadding='5' cellspacing='0' border='0'>";
echo "<tr>\n";
echo "<td>Seller ID:</td>\n";
echo "<td>" . $row['sellerID'] . "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>First Name:</td>\n";
echo "<td><input type='text' name='first_name' value='" . $row['first_name'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Last Name:</td>\n";
echo "<td><input type='text' name='last_name' value='" . $row['last_name'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Company:</td>\n";
echo "<td><input type='text' name='company_farm' value='";
echo $farmname;
echo "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Street Address:</td>\n";
echo "<td><input type='text' name='address' value='" . $row['address'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>City or Town: </td>\n";
echo "<td><input type='text' name='city' value='" . $row['city'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Province or State:</td>\n";
echo "<td><input type='text' name='province' value='" . $row['province'] . "'></td>\n";
echo "</tr>\n";
echo "<tr> \n";
echo "<td>Postal or Zip Code:</td>\n";
echo "<td><input type='text' name='postal_code' value='" . $row['postal_code'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Country:</td>\n";
echo "<td><input type='text' name='country' value='" . $row['country'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Home Phone Number:</td>\n";
echo "<td><input type='text' name='home_phone' value='" . $row['home_phone'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Work Phone Number:</td>";
echo "<td><input type='text' name='work_phone' value='" . $row['work_phone'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Cell Phone Number:</td>";
echo "<td><input type='text' name='cell_phone' value='" . $row['cell_phone'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Fax Number:</td>";
echo "<td><input type='text' name='fax' value='" . $row['fax'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Email:</td>\n";
echo "<td><input type='text' name='email' value='" . $row['email'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Password:</td>\n";
echo "<td><input type='text' name='password' value='" . $row['password'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Secret Word:</td>\n";
echo "<td><input type='text' name='secret_word' value='" . $row['secret_word'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Website:</td>\n";
echo "<td><input type='text' name='website' value='" . $row['website'] . "'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Approved: </td>\n";
echo "<td>Yes&nbsp;</td><td>\n";
echo "<input <?php if ($row['approved'] == 'Yes') {echo 'checked'; } ?> type='radio' name='approved' value='Yes'>&nbsp;No&nbsp;<input <?php if ($row['approved'] == 'No') {echo 'checked'; } ?> type='radio' name='approved' value='No'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td colspan='2' align='right'><input type='submit' name='submit' value='Update'></td>\n";
echo "</tr>\n";
echo "</table>\n";
?>
</form>


0
ledaveCommented:
hi there,
you don't have to re-start the php again. I explain, you're already into php and in your echo you start another one.
Try this:
if ($row['approved'] == 'Yes'){
echo "<input type='radio' name='approved' value='Yes' checked>&nbsp;No&nbsp;<input type='radio' name='approved' value='No'></td>\n";
}else{
echo "<input type='radio' name='approved' value='Yes'>&nbsp;No&nbsp;<input type='radio' name='approved' value='No' checked ></td>\n";
}

instead of:
echo "<input <?php if ($row['approved'] == 'Yes') {echo 'checked'; } ?> type='radio' name='approved' value='Yes'>&nbsp;No&nbsp;<input <?php if ($row['approved'] == 'No') {echo 'checked'; } ?> type='radio' name='approved' value='No'></td>\n";

hope it helps
ledave
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
koochyAuthor Commented:
that did it .. thank you SOOOOOOOO much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.