In php:
$query ="SELECT rent FROM mydatabase WHERE rent= '$rent'";
$rs=mysqli_query($connect,$query);
if(!$rs)
{echo "<script type ='text/javascript'>alert('Cannot connect to database')</script>";
}
else
{ if(mysqli_num_rows($rs) != 0)
{die("<script type ='text/javascript'>alert('The selected room are not available')</script>");}
}
$sql = "INSERT INTO mydatabase(title,first_name,last_name,dob,email,id,password,rent) VALUES('$title','$first_name','$last_name','$dob','$email','$id','$password','$rent')";
mysqli_query($connect,$sql);
$_SESSION['first_name'] = $first_name;
$_SESSION['rent'] = $rent;
header("location: database.php");
In html:
<select name = "rent">
<option></option>
<option name= "rent" value="A1">A1</option>>
<option name= "rent" value="A10">A10</option>
<option name= "rent" value="A3">A3</option>
<option name= "rent" value="A4">A4</option>
<option name= "rent" value="A5">A5</option>
<option name= "rent" value="A15">A15</option>
<option name= "rent" value="A20">A20</option>
<option name= "rent" value="A8">A8</option>
<option name= "rent" value="A6">A6</option>
<option name= "rent" value="A12">A12</option>
</select>
Here,I want to set unique for rent value. For example, if customer had selected rent value 'A1' again he cannot select the same value. The problem is I also want to set the empty option for customer which does not want to select any option and store their data in database. But the empty option () cannot be entered two time. So what the thing can I give to overcome this. Ps. I am totally amateur and my English is not so good. Thank You :)