• OK, it's on.
  • Please note that many, many Email Addresses used for spam, are not accepted at registration. Select a respectable Free email.
  • Done now. Domine miserere nobis.

PHP/MySQL

Ulysses

Banned
Local time
Today 5:29 AM
Joined
Apr 26, 2009
Messages
307
---
Location
canada
Not a wizard, but I can still go over your code (if any) and see where you've gone wrong.
 

walfin

Democrazy
Local time
Today 1:29 PM
Joined
Mar 3, 2008
Messages
2,436
---
Location
/dev/null
Noddy why don't you just post your question.

Even wizards would be modest on INTPf.
 

Razare

Well-Known Member
Local time
Today 12:29 AM
Joined
Apr 11, 2009
Messages
633
---
Location
Michigan - By Lake Michigan
I've used both before. The problem with that stuff is once you're out of it for a while you forget the details. I could pick it up again pretty easily, but no, I wouldn't be a wizard presently.

I do recall getting apache + mySQL + php all working harmoniously on windows was difficult.
 

EloquentBohemian

MysticDragon
Local time
Today 12:29 AM
Joined
Oct 4, 2008
Messages
1,386
---
Location
Ottawa, Canada
Apache + mySQL + php work so much better on Unix. I had to shift to Unix on my ISP when I uploaded Wordpress for the blog part of my site.
What's your problem with php/mySQL, Noddy?
 

NoID10ts

aka Noddy
Local time
Yesterday 11:29 PM
Joined
Jul 14, 2008
Messages
4,541
---
Location
Houston, TX
Your new avatar is disturbing as hell, EB. :D

Man, I forgot I created this thread. I'm mainly just being lazy, I think I can figure it out, but I thought that maybe someone with a lot of expertise could save me some time. ;)

I work at a middle school and a couple of years ago I created an employee portal using mainly php/mysql. I had no prior experience with php/mysql, but the school bought me some books and I muddled through it. It may not be pretty, it may not be up to proper coding standards, but it works like a charm and that's all I care about.

One of the parts of the portal is a computer lab reservation form. The way it works is there is a list of available dates, the available class periods for each date, and a little box that says "Reserve" for each period. All they have to do is click "Reserve" and it inserts their username in that slot.

I also programed it so that it compares the usernames in the reserved slots and the currently logged in user and where there is a match they can delete their reservation. This way they can only delete their own reservations and no one elses. Of course, being a form of a God, I have the ability to delete everyone. :evil:

Here's what it looks like:

attachment.php


Now the only problem I have is that the teachers started complaining that some people were either reserving huge blocks of time, were only reserving so they could babysit (just let the kids play games), or they wouldn't show up for the reservation which left an open lab that could be used by someone else.

Therefore, I need to design a way to limit the number of reservations to 15 periods at a time. This will eliminate the mass reservations, and force them to really consider whether they need it or not, since they have a finite number of reservations.

It will have to take into account the present day and all days beyond it, but not past days. If the count goes over 15, it should give them a message like "You have exceeded your alloted number of reservations."

I think this should be easy, but it's been so long since I did this. Here's the present code (don't laugh, geniuses, like I said, it works):

<?php require_once('Connections/jms_portal.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "1,2,3,4";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
// technocurve arc 3 php mv block1/3 start
$mocolor1 = "#E7CEFF";
$mocolor2 = "#F7F7F7";
$mocolor3 = "#C1BEDE";
$mocolor = $mocolor1;
// technocurve arc 3 php mv block1/3 end
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "am")) {
$user=($_SESSION['MM_Username']);
$id=($_POST['lab_id']);
$updateSQL = sprintf("UPDATE lab103 SET AMTutorial='$user' WHERE `lab_id`=$id",
GetSQLValueString(isset($_POST['amsubmit']), "text"),
GetSQLValueString($_POST['lab_id'], "int"));
mysql_select_db($database_jms_portal, $jms_portal);
$Result1 = mysql_query($updateSQL, $jms_portal) or die(mysql_error());
$updateGoTo = "lab103.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}

if((isset($_POST["MM_insert2"])) && ($_POST["MM_insert2"] == "one")) {
$user=($_SESSION['MM_Username']);
$id=($_POST['lab_id']);
$updateSQL = sprintf("UPDATE lab103 SET oneFive='$user' WHERE `lab_id`=$id",
GetSQLValueString(isset($_POST['onesubmit']), "text"),
GetSQLValueString($_POST['lab_id'], "int"));
mysql_select_db($database_jms_portal, $jms_portal);
$Result1 = mysql_query($updateSQL, $jms_portal) or die(mysql_error());
$updateGoTo = "lab103.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if((isset($_POST["MM_insert3"])) && ($_POST["MM_insert3"] == "spark")) {
$user=($_SESSION['MM_Username']);
$id=($_POST['lab_id']);
$updateSQL = sprintf("UPDATE lab103 SET SPARK='$user' WHERE `lab_id`=$id",
GetSQLValueString(isset($_POST['sparksubmit']), "text"),
GetSQLValueString($_POST['lab_id'], "int"));
mysql_select_db($database_jms_portal, $jms_portal);
$Result1 = mysql_query($updateSQL, $jms_portal) or die(mysql_error());
$updateGoTo = "lab103.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if((isset($_POST["MM_insert4"])) && ($_POST["MM_insert4"] == "two")) {
$user=($_SESSION['MM_Username']);
$id=($_POST['lab_id']);
$updateSQL = sprintf("UPDATE lab103 SET twoSix='$user' WHERE `lab_id`=$id",
GetSQLValueString(isset($_POST['twosubmit']), "text"),
GetSQLValueString($_POST['lab_id'], "int"));
mysql_select_db($database_jms_portal, $jms_portal);
$Result1 = mysql_query($updateSQL, $jms_portal) or die(mysql_error());
$updateGoTo = "lab103.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if((isset($_POST["MM_insert5"])) && ($_POST["MM_insert5"] == "three")) {
$user=($_SESSION['MM_Username']);
$id=($_POST['lab_id']);
$updateSQL = sprintf("UPDATE lab103 SET threeSeven='$user' WHERE `lab_id`=$id",
GetSQLValueString(isset($_POST['threesubmit']), "text"),
GetSQLValueString($_POST['lab_id'], "int"));
mysql_select_db($database_jms_portal, $jms_portal);
$Result1 = mysql_query($updateSQL, $jms_portal) or die(mysql_error());
$updateGoTo = "lab103.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if((isset($_POST["MM_insert6"])) && ($_POST["MM_insert6"] == "four")) {
$user=($_SESSION['MM_Username']);
$id=($_POST['lab_id']);
$updateSQL = sprintf("UPDATE lab103 SET fourEight='$user' WHERE `lab_id`=$id",
GetSQLValueString(isset($_POST['foursubmit']), "text"),
GetSQLValueString($_POST['lab_id'], "int"));
mysql_select_db($database_jms_portal, $jms_portal);
$Result1 = mysql_query($updateSQL, $jms_portal) or die(mysql_error());
$updateGoTo = "lab103.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if((isset($_POST["MM_insert7"])) && ($_POST["MM_insert7"] == "pm")) {
$user=($_SESSION['MM_Username']);
$id=($_POST['lab_id']);
$updateSQL = sprintf("UPDATE lab103 SET PMTutorial='$user' WHERE `lab_id`=$id",
GetSQLValueString(isset($_POST['pmsubmit']), "text"),
GetSQLValueString(isset($_POST['lab_id']), "int"));
mysql_select_db($database_jms_portal, $jms_portal);
$Result1 = mysql_query($updateSQL, $jms_portal) or die(mysql_error());
$updateGoTo = "lab103.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
?>
<?php
if($_SESSION['MM_UserGroup'] == '4'){
require_once('nav_tech.dwt.php');
}
elseif($_SESSION['MM_UserGroup'] == '3'){
require_once('nav_admin.dwt.php');
}
elseif($_SESSION['MM_UserGroup'] == '2'){
require_once('nav_faculty.dwt.php');
}
elseif($_SESSION['MM_UserGroup'] == '1'){
require_once('nav_teach.dwt.php');
}
?>
<?php
$maxRows_lab103 = 30;
$pageNum_lab103 = 0;
if (isset($_GET['pageNum_lab103'])) {
$pageNum_lab103 = $_GET['pageNum_lab103'];
}
$startingRow = date("Y-m-d");
$startRow_lab103 = $pageNum_lab103 * $maxRows_lab103;
mysql_select_db($database_jms_portal, $jms_portal);
$query_lab103 = "SELECT * FROM `lab103` WHERE `Date` >= '$startingRow'";
$query_limit_lab103 = sprintf("%s LIMIT %d, %d", $query_lab103, $startRow_lab103, $maxRows_lab103);
$lab103 = mysql_query($query_limit_lab103, $jms_portal) or die(mysql_error());
$row_lab103 = mysql_fetch_assoc($lab103);
if (isset($_GET['totalRows_lab103'])) {
$totalRows_lab103 = $_GET['totalRows_lab103'];
} else {
$all_lab103 = mysql_query($query_lab103);
$totalRows_lab103 = mysql_num_rows($all_lab103);
}
$totalPages_lab103 = ceil($totalRows_lab103/$maxRows_lab103)-1;
$queryString_lab103 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_lab103") == false &&
stristr($param, "totalRows_lab103") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_lab103 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_lab103 = sprintf("&totalRows_lab103=%d%s", $totalRows_lab103, $queryString_lab103);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>JMS Portal - Lab 103</title>
<style type="text/css">
<!--
.style1 {font-size: x-large}
.style2 {font-size: medium}
.style3 {font-size: large}
.style4 {color: #FF0000}
body {
background-color: #CCCCCC;
}
-->
</style></head>
<body>
<table width="941" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="2">
<p align="center"><span class="style1"><u>Lab 103</u></span></p>
<ul>
<li><strong align="center"> Computer Lab 103 has 30 student computers, 1 teacher computer, a ceiling mounted projector, and a SMARTboard</strong></li>
<li><strong><u><span class="style4">Clean Slate is installed on all computers in the 103 </span></u> so all saving must be done to the resource drive (johnston-rs02) or in the &quot;My Documents&quot; folder with the student profile. If you do not have a folder on the resource drive please contact <a href="<A href="mailto:csmith35@houstonisd.org">Ches">mailto:csmith35@houstonisd.org">Ches Smith </a></strong></li>
<li><strong>To reserve a lab just check the date and period you need and click reserve if it is available</strong></li>
<li><strong>If you decide you do not need the lab later, just click on your username to cancel it </strong></li>
</ul>
<table width="887" border="2" align="center">
<tr bgcolor=#EBF3FE>
<th width="121" scope="col"><span class="style2">Date</span></th>
<th width="100" scope="col"><span class="style2">AM Tutorial</span></th>
<th width="100" scope="col"><span class="style2">1st/5th</span></th>
<th width="100" scope="col"><span class="style2">SPARK</span></th>
<th width="100" scope="col"><span class="style2">2nd/6th</span></th>
<th width="100" scope="col"><span class="style2">3rd/7th</span></th>
<th width="100" scope="col"><span class="style2">4th/8th</span></th>
<th width="100" scope="col"><span class="style2">PM Tutorial </span></th>
</tr>
<?php do { ?>
<tr <?php
// technocurve arc 3 php mv block2/3 start
echo " style=\"background-color:$mocolor\" onMouseOver=\"this.style.backgroundColor='$mocolor3'\" onMouseOut=\"this.style.backgroundColor='$mocolor'\"";
// technocurve arc 3 php mv block2/3 end
?> >
<td><?php
if($row_lab103['Day']=="Purple Day") {
echo "<b>$row_lab103[Date]</b>";
}
elseif($row_lab103['Day']=="Purple Day (ED)") {
echo "<b>$row_lab103[Date] (ED)</b>";
}
elseif($row_lab103['Day']=="Gray Day"){
echo "<b>$row_lab103[Date]</b>";
}
elseif($row_lab103['Day']=="Gray Day (ED)") {
echo "<b>$row_lab103[Date] (ED)</b>";
}
?></td>
<form id="am" name="am" method="POST" action="<?php echo $editFormAction; ?>">
<td><div align="center">
<?php
if($row_lab103['AMTutorial'] == NULL){
echo "<input name='amsubmit' type='submit' id='amsubmit' value='Reserve'>";
echo "<input type='hidden' name='lab_id' value='$row_lab103[lab_id]'>";
echo "<input type='hidden' name='MM_insert' value='am'>";
}
elseif($row_lab103['AMTutorial']==$_SESSION['MM_Username']){
echo "<a href='delete103.php?lab_id1=$row_lab103[lab_id]'><b><i><font color=purple>$_SESSION[MM_Username]</i></b></a>";
}
elseif($_SESSION['MM_UserGroup']=='4'){
echo "<a href='delete103.php?lab_id1=$row_lab103[lab_id]'><b><i><font color=purple>$row_lab103[AMTutorial]</i></b></a>";
}
else {
echo "<b><i><font color=purple>$row_lab103[AMTutorial]</i></b>";
}
?>
</div></td>
</form>
<form id="one" name="one" method="POST" action="<?php echo $editFormAction; ?>">
<td><div align="center">
<?php
if($row_lab103['oneFive'] == NULL){
echo "<input name='onesubmit' type='submit' id='onesubmit' value='Reserve'>";
echo "<input type='hidden' name='lab_id' value='($row_lab103[lab_id])'>";
echo "<input type='hidden' name='MM_insert2' value='one'>";
}
elseif($row_lab103['oneFive']==$_SESSION['MM_Username']){
echo "<a href='delete103.php?lab_id2=$row_lab103[lab_id];'><b><i><font color=purple>$_SESSION[MM_Username]</i></b></a>";
}
elseif($_SESSION['MM_UserGroup']=='4'){
echo "<a href='delete103.php?lab_id2=$row_lab103[lab_id]'><b><i><font color=purple>$row_lab103[oneFive]</i></b></a>";
}
else {
echo "<b><i><font color=purple>$row_lab103[oneFive]</i></b>";
}
?>
</div></td>
</form>
<form id="spark" name="spark" method="POST" action="<?php echo $editFormAction; ?>">
<td><div align="center">
<?php
if($row_lab103['SPARK'] == NULL){
echo "<input name='sparksubmit' type='submit' id='sparksubmit' value='Reserve'>";
echo "<input type='hidden' name='lab_id' value='$row_lab103[lab_id]'>";
echo "<input type='hidden' name='MM_insert3' value='spark'>";
}
elseif($row_lab103['SPARK']==$_SESSION['MM_Username']){
echo "<a href='delete103.php?lab_id3=$row_lab103[lab_id];'><b><i><font color=purple>$_SESSION[MM_Username]</i></b></a>";
}
elseif($_SESSION['MM_UserGroup']=='4'){
echo "<a href='delete103.php?lab_id3=$row_lab103[lab_id]'><b><i><font color=purple>$row_lab103[SPARK]</i></b></a>";
}
else {
echo "<b><i><font color=purple>$row_lab103[SPARK]</i></b>";
}
?>
</div></td>
</form>
<form id="two" name="two" method="POST" action="<?php echo $editFormAction; ?>">
<td><div align="center">
<?php
if($row_lab103['twoSix'] == NULL){
echo "<input name='twosubmit' type='submit' id='twosubmit' value='Reserve'>";
echo "<input type='hidden' name='lab_id' value='$row_lab103[lab_id]'>";
echo "<input type='hidden' name='MM_insert4' value='two'>";
}
elseif($row_lab103['twoSix']==$_SESSION['MM_Username']){
echo "<a href='delete103.php?lab_id4=$row_lab103[lab_id];'><b><i><font color=purple>$_SESSION[MM_Username]</i></b></a>";
}
elseif($_SESSION['MM_UserGroup']=='4'){
echo "<a href='delete103.php?lab_id4=$row_lab103[lab_id]'><b><i><font color=purple>$row_lab103[twoSix]</i></b></a>";
}
else {
echo "<b><i><font color=purple>$row_lab103[twoSix]</i></b>";
}
?>
</div></td>
</form>
<form id="three" name="three" method="POST" action="<?php echo $editFormAction; ?>">
<td><div align="center">
<?php
if($row_lab103['threeSeven'] == NULL){
echo "<input name='threesubmit' type='submit' id='threesubmit' value='Reserve'>";
echo "<input type='hidden' name='lab_id' value='$row_lab103[lab_id]'>";
echo "<input type='hidden' name='MM_insert5' value='three'>";
}
elseif($row_lab103['threeSeven']==$_SESSION['MM_Username']){
echo "<a href='delete103.php?lab_id5=$row_lab103[lab_id];'><b><i><font color=purple>$_SESSION[MM_Username]</i></b></a>";
}
elseif($_SESSION['MM_UserGroup']=='4'){
echo "<a href='delete103.php?lab_id5=$row_lab103[lab_id]'><b><i><font color=purple>$row_lab103[threeSeven]</i></b></a>";
}
else {
echo "<b><i><font color=purple>$row_lab103[threeSeven]</i></b>";
}
?>
</div></td>
</form>
<form id="four" name="four" method="POST" action="<?php echo $editFormAction; ?>">
<td><div align="center">
<?php
if($row_lab103['fourEight'] == NULL){
echo "<input name='foursubmit' type='submit' id='foursubmit' value='Reserve'>";
echo "<input type='hidden' name='lab_id' value='$row_lab103[lab_id]'>";
echo "<input type='hidden' name='MM_insert6' value='four'>";
}
elseif($row_lab103['fourEight']==$_SESSION['MM_Username']){
echo "<a href='delete103.php?lab_id6=$row_lab103[lab_id];'><b><i><font color=purple>$_SESSION[MM_Username]</i></b></a>";
}
elseif($_SESSION['MM_UserGroup']=='4'){
echo "<a href='delete103.php?lab_id6=$row_lab103[lab_id]'><b><i><font color=purple>$row_lab103[fourEight]</i></b></a>";
}
else {
echo "<b><i><font color=purple>$row_lab103[fourEight]</i></b>";
}
?>
</div></td>
</form>
<form id="pm" name="pm" method="POST" action="<?php echo $editFormAction; ?>">
<td><div align="center">
<?php
if($row_lab103['PMTutorial'] == NULL){
echo "<input name='pmsubmit' type='submit' id='pmsubmit' value='Reserve'>";
echo "<input type='hidden' name='lab_id' value='$row_lab103[lab_id]'>";
echo "<input type='hidden' name='MM_insert7' value='pm'>";
}
elseif($row_lab103['PMTutorial']==$_SESSION['MM_Username']){
echo "<a href='delete103.php?lab_id7=$row_lab103[lab_id];'><b><i><font color=purple>$_SESSION[MM_Username]</i></b></a>";
}
elseif($_SESSION['MM_UserGroup']=='4'){
echo "<a href='delete103.php?lab_id7=$row_lab103[lab_id]'><b><i><font color=purple>$row_lab103[PMTutorial]</i></b></a>";
}
else {
echo "<b><i><font color=purple>$row_lab103[PMTutorial]</i></b>";
}
?>
</div></td>
</form>
</tr>

<?php
// technocurve arc 3 php mv block3/3 start
if ($mocolor == $mocolor1) {
$mocolor = $mocolor2;
} else {
$mocolor = $mocolor1;
}
// technocurve arc 3 php mv block3/3 end
?> <?php } while ($row_lab103 = mysql_fetch_assoc($lab103)); ?>
</table>
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center"><?php if ($pageNum_lab103 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_lab103=%d%s", $currentPage, 0, $queryString_lab103); ?>">First</a>
<?php } // Show if not first page ?>
</td>
<td width="31%" align="center"><?php if ($pageNum_lab103 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_lab103=%d%s", $currentPage, max(0, $pageNum_lab103 - 1), $queryString_lab103); ?>">Previous</a>
<?php } // Show if not first page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_lab103 < $totalPages_lab103) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_lab103=%d%s", $currentPage, min($totalPages_lab103, $pageNum_lab103 + 1), $queryString_lab103); ?>">Next</a>
<?php } // Show if not last page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_lab103 < $totalPages_lab103) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_lab103=%d%s", $currentPage, $totalPages_lab103, $queryString_lab103); ?>">Last</a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>
</p>
<p></p>
</td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($lab103);
?>
 
Last edited:

Artifice Orisit

Guest
Now the only problem I have is that the teachers started complaining that some people were either reserving huge blocks of time, were only reserving so they could babysit (just let the kids play games), or they wouldn't show up for the reservation which left an open lab that could be used by someone else.
Just tell them to f**k off and stop bothering IT staff with HR issues.
 

Razare

Well-Known Member
Local time
Today 12:29 AM
Joined
Apr 11, 2009
Messages
633
---
Location
Michigan - By Lake Michigan
When they activate a button by clicking on it, perform a loop search that goes through the entire list of reservations. Have it count the number of times their user name appears and if it exceeds 15, cancel out of the reservation process and just display text at the top of the page or some such saying they're at their limit.

I don't have a PhP editor currently and trying to view that stuff without formatting is impossible, but that's the basics of what should be done.
 

Razare

Well-Known Member
Local time
Today 12:29 AM
Joined
Apr 11, 2009
Messages
633
---
Location
Michigan - By Lake Michigan
Well let me put a disclaimer on that. That's the solution if your list is only a few hundred units long. Since they can reserve weeks in advance, I presume, you may have a list of many thousands of units. If this is the case you may want to store data containing the number of reservations for each user, incrementing and decrementing as necessary. That's the more efficient solution if it's large.
 

NoID10ts

aka Noddy
Local time
Yesterday 11:29 PM
Joined
Jul 14, 2008
Messages
4,541
---
Location
Houston, TX
I know what needs to happen, I'm just wondering if anyone knows what the code would actually look like.

Off the top of my head it would be something like:

If userid = current user
then count all occurences from today's date, and beyond
create variable with that number
If variable > 15 then echo "you have exceeded your allotted number of reservations"

I'm just not sure of the correct verbage to make this happen, nor where I need to insert it into the code I posted previously.

I'll figure it out, but like I said before, I'm lazy. Or am I too busy to get to it? I don't know.

And Cog, I wish I could say something like that, but I actually am a school administrator, so there is an hr component to my job especially where computers and computer labs are concerned. I even have to do a bit of training at times.
 

Artifice Orisit

Guest
And Cog, I wish I could say something like that, but I actually am a school administrator, so there is an hr component to my job especially where computers and computer labs are concerned. I even have to do a bit of training at times.
Aww that sucks all the fun out of being a bad employee, but at least you're trying to ego trip random people into doing your work for you.
*two thumbs up and a broad smile on his face*
Way to go! :D
 

Felan

Prolific Member
Local time
Yesterday 11:29 PM
Joined
Apr 20, 2009
Messages
1,064
---
Location
Unauthorized personnel only
Let me preface with I'm familiar with .NET and SQL Server.

Looping in code or keeping a field in the database to track that information seems unnecessary when most SQL implementations offer date comparisons and count function, I would be hard-pressed to believe MySQL lacks these. If the query returns a count that is 15 or greater for the logged in user than display a message and disable the Reserve buttons so they don't get a chance to click any of them.

Additionally you can re-use the function to quickly verify that they don't have 15 reservations in the database. So if they did circumvent your protection (multiple sessions or javascript hacks) you would catch it server side and deny them there.
 
Last edited:

walfin

Democrazy
Local time
Today 1:29 PM
Joined
Mar 3, 2008
Messages
2,436
---
Location
/dev/null
"SELECT * FROM lab103 WHERE AMTutorial='".$_SESSION('MM_Username')."' OR PMTutorial='".$_SESSION('MM_Username')

etc etc. for SPARK et al.

Maybe you can store the field names in an array and iterate through a for loop to build the query.

add your date requirements in the query, count the rows in the recordset (sorry I don't know what the mysql term is, I used to use ADO, the old one). Why'd that be hard? Make the DBMS do the work.

Or maybe I didn't really understand your question, I'm a little rusty, sorry. Speed shouldn't be that much of a concern, right?
 
Top Bottom