Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- /* Переменные для соединения с базой данных */
- $hostname = "localhost";
- $username = "root";
- $password = "";
- $dbName = "video";
- /* Таблица MySQL, в которой хранятся данные */
- $filmstable = "films";
- $customerstable = "customers";
- $orderstable = "orders";
- /* создать соединение */
- mysql_connect($hostname,$username,$password) OR DIE("Can not establish connection");
- /* выбрать базу данных. Если произойдет ошибка - вывести ее */
- mysql_select_db($dbName) or die(mysql_error());
- $namefilm = $_GET['film'];
- $namecustomer = $_GET['customer'];
- $date = $_GET['date'];
- $returndate = $_GET['returndate'];
- $query = "SELECT $customerstable.*, $filmstable.* FROM $filmstable, $customerstable WHERE $filmstable.name_film = '$namefilm' AND $customerstable.name_customer = '$namecustomer' ";
- $res = mysql_query($query) or die(mysql_error());
- echo $query;
- $number_orders = mysql_num_rows($res);
- if($number_orders == 0) {
- echo "<CENTER><P>No films or customers with this name found in the database</CENTER>";
- }
- $query = "INSERT INTO $orderstable (id_film, id_customer, order_date, expiration_date) VALUES('$filmstable.id_film', '$customerstable.id_customer', '$date', .$returndate)";
- /* Выполнить запрос. Если произойдет ошибка - вывести ее. */
- mysql_query($query) or die(mysql_error());
- echo "Order: ".$namefilm." for ".$namecustomer." from ".$date." until ".$returndate." was added.<BR>";
- /* Закрыть соединение */
- mysql_close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement