I have a script which is used to edit login information in a database. I have everything setup to work so that when you login there is a link which will take you to the appropriate edit page. However, I have a select box, and it shows the default value, rather than what the user has entered in the database for that selection.
How can I make it so that the select box has a different value based on what was entered in the db?
<link href="bord.css" rel="stylesheet" type="text/css">
<?php
include("dbconn.php"); // Connect to the DB
if ($id) { // If the id is the same as in the db
if($submit) { // If submitted the form
$sql = "UPDATE characters SET cName='$txtName',cPass='$txtPass',cEmpire='$txtEmpire',cRank='$txtRank',cCRank='$txtCRank',cOutfit='$txtOutfit' WHERE id=".$id;
$result = mysql_query($sql);
echo "Thank you, information updated.\n";
} else {
$sql = "SELECT * FROM characters WHERE id=".$id;
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
}
}
?>
<form method="post" action="<?php echo $PHP_SELF?>">
First name:<input class="text" type="Text" name="txtName" value="<?php echo $myrow["cName"] ?>"><br>
Password: <br><input class="text" type="Text" name="txtPass" value="<?php echo $myrow["cPass"] ?>"><br>
Empire: <br><select class="text" name="txtEmpire">
<option value="empire_vs-logo.gif">Vanu Sovereignty</option>
<option value="empire_tr-logo.gif">Terran Republic</option>
<option value="empire_nc-logo.gif">New Conglomerate</option>
</select><br>
Rank: <br><input class="text" type="Text" name="txtRank" value="<?php echo $myrow["cRank"] ?>"><br>
Command Rank: <br><input class="text" type="Text" name="txtCRank" value="<?php echo $myrow["cCRank"] ?>"><br>
Outfit: <br><input class="text" type="Text" name="txtOutfit" value="<?php echo $myrow["cOutfit"] ?>"><br>
<input class="submit" type="Submit" name="submit" value="Enter information">
<input type="hidden" name="id" value="<?php echo $myrow["id"] ?>">
</form>
Thanks for all the help!