【发布时间】:2014-05-24 05:16:44
【问题描述】:
我对 php 和数据库还很陌生,我使用 xampp 创建了一个预订系统。我有一个供用户预订的登录页面和一个供管理员查看所有预订的限制访问页面。但是,我似乎无法查看每个人所做的所有预订,而只能查看用户所做的预订。我确定这与会话有关,但不确定是哪一部分。帮助将不胜感激。
这里是下面的记录集代码,它只显示登录了预订的用户,而不是所有的数据库预订。
谢谢
<?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);
?>
【问题讨论】:
-
您可能会考虑使用这样的框架。我个人喜欢 CodeIgniter。它将有助于避免像您这样的混乱数据库代码......