简体   繁体   English

PHP预订系统数据库

[英]PHP Booking system database

I'm fairly new to php and databases, i have created a booking system using xampp. 我是php和数据库的新手,我使用xampp创建了一个预订系统。 i have a log in page for users to book and a restrict access page for admin to view all of the bookings that have been made. 我有一个登录页面供用户预订,限制访问页面供管理员查看已经完成的所有预订。 however i cannot seem to view all the bookings that have been made by everyone only the bookings that have been made by the user. 但是我似乎无法查看每个人所做的所有预订,只有用户做出的预订。 I'm sure it is something to do with the session but unsure which part. 我确信它与会话有关但不确定哪个部分。 help would be appreciated. 帮助将不胜感激。

here is the following recordset code which displays only the user who has logged ins booking and not all of the databases booking. 这是以下记录集代码,它仅显示已登录的用户,而不是所有预订的数据库。

thank you 谢谢

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) :     mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;    
case "long":
case "int":
  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  break;
case "double":
  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  break;
case "date":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;
case "defined":
  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  break;
 }
 return $theValue;
}
}

$colname_Recordset1 = "-1";
if (isset($_SESSION['MM_Userid'])) {
$colname_Recordset1 = $_SESSION['MM_Userid'];
}
mysql_select_db($database_myconnectiono, $myconnectiono);
$query_Recordset1 = sprintf("SELECT * FROM booking WHERE user_id = %s",     GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $myconnectiono) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);


?>

Your query limits it to one user only. 您的查询仅限于一个用户。

$query_Recordset1 = sprintf("SELECT * FROM booking WHERE user_id = %s", GetSQLValueString($colname_Recordset1, "int"));

Where is says WHERE user_id = %s will limit the results to only that user's results. 在哪里说WHERE user_id = %s会将结果限制为仅该用户的结果。 Remove that and you will get all of the bookings. 删除它,您将获得所有预订。

$query_Recordset1 = "SELECT * FROM booking";

You probably will want to improve that query by ordering the results by user, date, etc. 您可能希望通过按用户,日期等排序结果来改进该查询。

Change this line: 改变这一行:

$query_Recordset1 = sprintf("SELECT * FROM booking WHERE user_id = %s", GetSQLValueString($colname_Recordset1, "int"));

To: 至:

$query_Recordset1 = sprintf("SELECT * FROM booking", GetSQLValueString($colname_Recordset1, "int"));

By removing the WHERE user_id = %s all the rows in the bookings table will be returned. 通过删除WHERE user_id = %s ,将返回预订表中WHERE user_id = %s所有行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM