I can't get my dropdown menu (in edit.php) to select the option that i choose. I can also not edit the value through text form, it just gets submited but nothing happends (I can edit other values with it)
Ive already tried with no luck
<?php
if($row["rank"]=='Unranked')
{
echo "Unranked";
}
?>
This is my option code
<select id="rank" name="rank">
<option value = "No Selected">Select a rank</option>
<option value = "Unranked">Unranked</option>
<option value = "Silver 1">Silver 1</option>
<option value = "Silver 2">Silver 2</option>
<option value = "Silver 3">Silver 3</option>
<option value = "Silver 4">Silver 4</option>
<option value = "Silver Elite">Silver Elite</option>
<option value = "Silver Elite Master">Silver Elite Master</option>
<option value = "Gold Nova 1">Gold Nova 1</option>
<option value = "Gold Nova 2">Gold Nova 2</option>
<option value = "Gold Nova 3">Gold Nova 3</option>
<option value = "Gold Nova master">Gold Nova master</option>
<option value = "Master Guardian 1">Master Guardian 1</option>
<option value = "Master Guardian 2">Master Guardian 2</option>
<option value = "Master Guardian Elite">Master Guardian Elite</option>
<option value = "Distinguished Master Guardian">Distinguished Master Guardian</option>
<option value = "Legendary Eagle">Legendary Eagle</option>
<option value = "Legendary Eagle Master">Legendary Eagle Master</option>
<option value = "Supreme">Supreme Master First Class</option>
<option value = "Global Elite">Global Elite</option>
</select>
I would like it to auto select the selected option and to acctually work
EDIT 54523(im new to this site sigh):
<?php
// including the database connection file
include_once("config.php");
if(isset($_POST['update']))
{
$Id = $_POST['Id'];
$username=$_POST['username'];
$password=$_POST['password'];
$friendcode=$_POST['friendcode'];
$rank = $_POST['rank'];
$lvl = $_POST['lvl'];
// checking empty fields
if(empty($username) || empty($password) || empty($friendcode) || empty($rank) || empty($lvl)) {
if(empty($username)) {
echo "<font color='red'>Please enter a username</font><br/>";
}
if(empty($password)) {
echo "<font color='red'>Please enter a password</font><br/>";
}
if(empty($friendcode)) {
echo "<font color='red'>Please enter a friendcode</font><br/>";
}
if(empty($rank)) {
echo "<font color='red'>Please select a rank</font><br/>";
}
if(empty($lvl)) {
echo "<font color='red'>Please select a level</font><br/>";
}
} else {
//updating the table
$result = mysqli_query($mysqli, "UPDATE legit SET username='$username',password='$password',friendcode='$friendcode' WHERE Id=$Id");
//redirectig to the display page. In our case, it is index.php
header("Location: index.php");
}
}
?>
<?php
//getting id from url
$Id = $_GET['Id'];
//selecting data associated with this particular id
$result = mysqli_query($mysqli, "SELECT * FROM legit WHERE Id=$Id");
while($res = mysqli_fetch_array($result))
{
$username= $res['username'];
$password= $res['password'];
$friendcode= $res['friendcode'];
$rank= $res['rank'];
$lvl= $res['lvl'];
}
?>
<html>
<head>
<title>Edit account ID <?php echo $Id;?></title>
</head>
<body>
<div align="center">
<a href="index.php">Go back to account list</a>
<br/><br/>
<form name="form1" method="post" action="edit.php">
<table border="0">
<tr>
<td>Username</td>
<td><input type="text" name="username" value="<?php echo $username;?>"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="text" name="password" value="<?php echo $password;?>"></td>
</tr>
<tr>
<td>Friendcode</td>
<td><input type="text" name="friendcode" value="<?php echo $friendcode;?>"></td>
</tr>
<tr>
<td>Rank</td>
<td>
<select id="rank" name="rank">
<option value = "No Selected">Select a rank</option>
<option value = "Unranked">Unranked</option>
<option value = "Silver 1">Silver 1</option>
<option value = "Silver 2">Silver 2</option>
<option value = "Silver 3">Silver 3</option>
<option value = "Silver 4">Silver 4</option>
<option value = "Silver Elite">Silver Elite</option>
<option value = "Silver Elite Master">Silver Elite Master</option>
<option value = "Gold Nova 1">Gold Nova 1</option>
<option value = "Gold Nova 2">Gold Nova 2</option>
<option value = "Gold Nova 3">Gold Nova 3</option>
<option value = "Gold Nova master">Gold Nova master</option>
<option value = "Master Guardian 1">Master Guardian 1</option>
<option value = "Master Guardian 2">Master Guardian 2</option>
<option value = "Master Guardian Elite">Master Guardian Elite</option>
<option value = "Distinguished Master Guardian">Distinguished Master Guardian</option>
<option value = "Legendary Eagle">Legendary Eagle</option>
<option value = "Legendary Eagle Master">Legendary Eagle Master</option>
<option value = "Supreme">Supreme Master First Class</option>
<option value = "Global Elite">Global Elite</option>
</select>
</td>
</tr>
</tr>
<tr>
<td><input type="hidden" name="Id" value=<?php echo $_GET['Id'];?>></td>
<td><input type="submit" name="update" value="Update"></td>
</tr>
</table>
</form>
</div>
</body>
</html>