gpt4 book ai didi

PHP预订系统数据库

转载 作者:行者123 更新时间:2023-11-29 08:04:33 26 4
gpt4 key购买 nike

我对 php 和数据库相当陌生,我使用 xampp 创建了一个预订系统。我有一个供用户预订的登录页面和一个供管理员查看所有已预订的限制访问页面。但是,我似乎无法查看每个人所做的所有预订,只能查看用户所做的预订。我确信这与 session 有关,但不确定是哪一部分。如有帮助,将不胜感激。

以下记录集代码仅显示已登录预订的用户,而不是所有数据库预订。

谢谢

<?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);


?>

最佳答案

您的查询仅限于一位用户。

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

Where 表示 WHERE user_id = %s 会将结果限制为仅该用户的结果。删除它,您将获得所有预订。

$query_Recordset1 = "SELECT * FROM booking";

您可能希望通过按用户、日期等对结果进行排序来改进该查询。

关于PHP预订系统数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22989058/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com