lundi 4 avril 2016

How to use if-else if or switch-case with database elements in PHP?

I am quite new to php and I need to solve this:

There is a registration form where you can select Name, Email and Time. Time has more options, of course.

I would like to add max registration number for times. I create a piece of code witch works for one time, but i don't really know how to make it work for one by one. My code is just an if statement, like this:

$check_reg_num = "SELECT * FROM database WHERE time='18:00'";
if ($result = mysqli_query($con, $check_reg_num)) {
$rowcount = mysqli_num_rows($result);
if ($rowcount >= 2) {
echo "<script>alert('Reg is full for this time or smthing like that')</script>";
}
exit();
}

This works just for 18:00 and if that is full, I cant reg any other time. I don't want to complicate, You know what i would like to achive :)

Thank You for every help.

Aucun commentaire:

Enregistrer un commentaire