Jump to content

help with script


lee2010

Recommended Posts

Hi all, i'm working on a script which will allow staff members or "admins" to move users on a html table. Basically a user clicks on a cell within a table and there username is stored in a mysql database and  there username also appears in that cell and its reserved for them and other users cant take there slot. I use this for a seating plan for events.

 

I have made an identical table which pulls the same data from the database but is only availible to staff members but i want it so when a staff member clicks on a cell or "seat" it will ask them if they want to move themselves there or another user. Here is my code i have so far:

 

<?php require ("./auth.php");?>
<?php require ("../secure/connect.php");?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SouthWest LAN's</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="../css/styles.css" />
</head>
<body>
<!-- Begin Wrapper -->
<div id="wrapper">
  <!-- Begin Header -->
  <div id="header"><h1><br />SouthWest LAN's</h1></div>
  <!-- End Header -->
  <!-- Begin Navigation -->
  <div id="navigation"><ul>
            <li style="margin-right:15px; display:inline;"><a href="../index.php">Home</a></li>
		<li style="margin-right:15px; display:inline;"><a href="../gallery/">Photo Gallery</a></li>
		<li style="margin-right:15px; display:inline;"><a href="../events.php">Events</a></li>
		<li style="margin-right:15px; display:inline;"><a href="../account.php">My Account</a></li>
		<li style="margin-right:15px; display:inline;"><a href="../forum.php">Forums</a></li>
		<li style="margin-right:15px; display:inline;"><a href="../faq.php">FAQ</a></li>
		</ul></div>
  <!-- End Navigation -->
  
  <!-- Begin Content Column -->
    <div id="content">
      <h1>Staff Seating</h1><br />
      <p>Below shows where users are currently seated and you can edit where users are sitting and place users that havent yet choosen a seat.</p><br />
  
  <p>Click a seat for options:</p><br />
  
<?php	

session_start();

$user_id = array();

$query = "SELECT * from seats_table";

$result = mysql_query($query);

while($row = mysql_fetch_array($result)){
$seat_status[] = $row['taken'];
}

$query5 = "SELECT * from seats_table";

$result5 = mysql_query($query5);

while($row5 = mysql_fetch_array($result5)){
$user_id[] = $row5['user_id'];
}



$get2 = mysql_query("SELECT * FROM users WHERE username='".$_SESSION['username']."'")or die(mysql_error());


?>

<fieldset>
<br />

<table width="100%" border="0" align="center">
<tr>
<td><b>Seat 01</b></td>
<td><b>Seat 02</b></td>
<td><b>Seat 03</b></td>
<td><b>Seat 04</b></td>
<td><b>Seat 05</b></td>
<td><b>Seat 06</b></td>
<td><b>Seat 07</b></td>
<td><b>Seat 08</b></td>
<td><b>Seat 09</b></td>
<td><b>Seat 10</b></td>
<td><b>Seat 11</b></td>
<td><b>Seat 12</b></td>
</tr>
<tr>
<td>Servers</td>
<td>Servers</td>
<td><?php if($seat_status[2]) { echo '<font color="red"><a href="admin_seat.php?seat=3">'.$user_id[2];} else { ?> <a href="admin_seat.php?seat=3"><font color="green">Availible</a></font><?php } ?></td>
<td><?php if($seat_status[3]) { echo '<font color="red"><a href="admin_seat.php?seat=4">'.$user_id[3];} else { ?> <a href="admin_seat.php?seat=4"><font color="green">Availible</a></font><?php } ?></td>
<td><?php if($seat_status[4]) { echo '<font color="red"><a href="admin_seat.php?seat=5">'.$user_id[4];} else { ?> <a href="admin_seat.php?seat=5"><font color="green">Availible</a></font><?php } ?></td>
<td><?php if($seat_status[5]) { echo '<font color="red"><a href="admin_seat.php?seat=6">'.$user_id[5];} else { ?> <a href="admin_seat.php?seat=6"><font color="green">Availible</a></font><?php } ?></td>
<td><?php if($seat_status[6]) { echo '<font color="red"><a href="admin_seat.php?seat=7">'.$user_id[6];} else { ?> <a href="admin_seat.php?seat=7"><font color="green">Availible</a></font><?php } ?></td>
<td><?php if($seat_status[7]) { echo '<font color="red"><a href="admin_seat.php?seat=8">'.$user_id[7];} else { ?> <a href="admin_seat.php?seat=8"><font color="green">Availible</a></font><?php } ?></td>
<td><?php if($seat_status[8]) { echo '<font color="red"><a href="admin_seat.php?seat=9">'.$user_id[8];} else { ?> <a href="admin_seat.php?seat=9"><font color="green">Availible</a></font><?php } ?></td>
<td><?php if($seat_status[9]) { echo '<font color="red"><a href="admin_seat.php?seat=10">'.$user_id[9];} else { ?> <a href="admin_seat.php?seat=10"><font color="green">Availible</a></font><?php } ?></td>
<td><?php if($seat_status[10]) { echo '<font color="red"><a href="admin_seat.php?seat=11">'.$user_id[10];} else { ?> <a href="admin_seat.php?seat=11"><font color="green">Availible</a></font><?php } ?></td>
<td><?php if($seat_status[11]) { echo '<font color="red"><a href="admin_seat.php?seat=12">'.$user_id[11];} else { ?> <a href="admin_seat.php?seat=12"><font color="green">Availible</a></font><?php } ?></td>
</tr>
</table>

<br />
</fieldset>
<br />

<SCRIPT LANGUAGE="JavaScript"> 
if (window.print) {
document.write('<form><input type=button name=print value="Print this page" onClick="window.print()"></form>');
}
</script>
  	 <br />
<hr /><br />

 

Above has been edited down to just show the first 12 seats.

 

And heres my admin_seat.php so far:

 

<?php
session_start();

/* connect to data base */
require ('../secure/connect.php');

/* get the seat number */
$seat_id = mysql_real_escape_string(trim($_GET['seat']));



?>

 

I want this script so that when i click on a seat it will ask me if i want to seat myself there, in which case it will place my username into that "seat" and remove anyone currently in that seat and reset them.

 

If i dont want to seat myself there i want the script to give me the option to place a user there, so i would need to list all of my registered users, ideally in a dropdown box (i will only have around 80 users tops) and then submit that and it will move that user to that seat and wipe there current seat if applicable.

 

something like this:

 

$query = "UPDATE seats_table set taken = FALSE, user_id = '0' WHERE user_id = '$user_id'";
$result = mysql_query($query) or die (mysql_error());
$query = "UPDATE seats_table set taken = TRUE, user_id = '$user_id'  WHERE id = '$seat_id'";
$result = mysql_query($query) or die (mysql_error());

 

the top line resets the seat back to default and availible for a user.

the third line is when a user selects a seat, it sets that seats "taken" to equal true stores there user ID and the seat ID.

 

any help with this would be great and also im not sure if its possible to list all of my registered users inside a dropdown box.

 

Lee

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.