Jump to content

checking database with php


dubc07

Recommended Posts

i have made a program that books airplanes using php and mysql

and pretty much everything has been covered except for the fack that people

can book over other reservations.

 

When booking i use variables such as this

$plane = '0';

$starttime ='800';

$endtime = '1000';

 

so this would make start time from 8am till 10am military time.

Is there a way to keep people from over booking by checking the data base for current start times and end times

then sending an error back refusing booking.

Link to comment
https://forums.phpfreaks.com/topic/117398-checking-database-with-php/
Share on other sites

I would need some more code of yours to help out more... but this about the concept in the code following. It checks to see if the subcategoryid is less than some number and greater than some number.  so use that to check to see whether your time is between those hours and change the variable names to match yours. hope it helps

 

 

<?php

require_once('dbconnect.php');

mysql_connect("$host", "$username", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

$myusername = $_SESSION['myusername'];

$rowalreadyexists = mysql_query("SELECT * FROM `users_subcategories` WHERE `users_subcategories`.`SubCategoryId` > 200 and `users_subcategories`.`SubCategoryId` < 300 and `users_subcategories`.`username` = '$myusername'") or die(mysql_error());

$rowcount = mysql_num_rows($rowalreadyexists);

if (!empty($_SESSION['myusername'])){

  if ($rowcount == 35) {

  echo '<img src="images/Fullcompletion2.gif" alt="100% completed" width="18" height="18" />';

}

else

    echo '<img src="images/0completion2.gif" alt="0% completed" width="18" height="18" />';

}

else

echo '<img src="images/0completion2.gif" alt="0% completed" width="18" height="18" />';

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.