This question already has an answer here:
I was trying to check whether a particular rno was existing in any specific table role. Both rno and role was fetched from html form. Could some one help?
<?php
$rno=$_POST['rno'];
$role=$_POST['role'];
$con = new mysqli("localhost", "root", "", "premierlg");
if ($con->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = mysqli_query($con, "SELECT * FROM" .$rno. " WHERE rno='".$rno."'");
if(mysqli_num_rows($query) > 0){
echo "Record already exists";
}else{
echo "Dosen't exist.";
if (!mysqli_query($con,$query))
{
die('Error: ' . mysqli_error($con));
}
}
?>
</div>