Retrieving Radio Values from Database with PHP MYSQL

Retrieving Radio Values from Database and Updating Form

Here is some code that shows 2 typical html radio buttons.

<p>
<label for="rel">Relative in Canada?:</label>
<input type="radio" name="member"  value="yes" /> Yes
<input type="radio" name="member"  value="no" /> No
</p>

Here is some code that shows 2 radio buttons that receive the value from the database. The chosen radio radio selection from the database will be automatically selected. This is a method which could be implemented when updating a database entry. The key is to pull the original values from the databse that were inserted from the original form.  With this update page, the new changes can be updated upon submit.

<p>
<label for="rel">Members in United States?:</label>
<?php
$command= "SELECT col1 FROM table where id='$my_id' AND member='yes'";
$result = mysqli_query($db, $command);
if ($result && mysqli_num_rows($result) ) {
while ($row = mysqli_fetch_assoc($result) >0) {
echo '<input type="radio" name="member"  value="yes" checked="checked" /> Yes';

}}
else { echo '<input type="radio" name="member"  value="yes"  /> Yes';
}?>

<?php
$command= "SELECT col1 FROM counselling_report where id='$report_id' AND member='no'";
$result = mysqli_query($db, $command);
if ($result && mysqli_num_rows($result) ) {
while ($row = mysqli_fetch_assoc($result)>0) {
echo '<input type="radio" name="member"  value="no" checked="checked" /> No';

}}
else { echo '<input type="radio" name="member"  value="no"  /> No';
}?>
</p>