PHP - Steps For Troubleshooting Script
I am creating an add on to a 3rd party CMS called Concrete5. Normally, when I have client issues, I can trace them to the server and fix them, however, this not doing so well on these issues. The following errors are being displayed in Chrome console:
Checking the server’s folder directory, it is true there is no concrete/fonts directory but there is a concrete/css/fonts directory with a couple of the missing files (but not glyphiconshalflings-regular.woff2).
Back to the errors, clicking the line number (i.e. 927, 3115, and 1), chrome blames apparently innocent line numbers.
What steps would you recommend taking to identify the cause and fix these errors? Similar TutorialsA friend of mine is looking at relaunching a site he used to run and I am going to try to persuade him to move over to a dynamic site. The site is a Football Clubs history site and contains around 2,000 games and several hundred players. The obvious advantage of a dynamic site is that even the bits I just mentioned run to around 2,500 static pages, which could be reduced to just 2 pages if dynamically driven. I am fairly confident that I can do the conversion, but there is one thing that I already know I may struggle with and that is the page which shows game, births and deaths on this day in history. A rough example (using a very heavy Javascript code) can be found at http://follyball.co.uk/jeff/. In a simplified form (ignoring for now the foreign keys to relationships that these tables actually have) there will be two tables GAMES game_id | date | competition | opponent | score | attendance PLAYERS player_id | surname | firstname | date of birth | date of death What I would be looking for is a way to take todays date, and find any corresponding records in games.date, players.date of birth, players.date of death on the same date in previous years. This would be simple to do as three different queries but as I would like to actually mix the three and show them in date order, I would like to do it in one query, presumably using UNIONS. On top of this, I would also like a slightly different output for each different set, for example, if it was a game I would like year, competition, opponent, score, attendance, Whereas if it is a players birth or death, I would like it to show something like firstname surname was born in year Before I go delving too deep into how it may be done, I would like to know if it can be done! I cannot see why it would not be able to generate this but if it is going to be way out of my ability, then I will look for another option! Thanks in advance Steve Hi all, I am sure this is simple, but I just can't wrap my head around a suitable way of doing this! Basically I have my JSON result as something like : Code: [Select] Array ( [result] => success [source] => gotBits [success] => 64 ) What I simply want to do is get the [success] output and store it as a variable. I have been looking at json_decode, but I cant find any examples for arrays, just strings? Can you push me in the right direction? So I've recently started looking into Character Encoding, after never really bothering with it, and I've got a few questions. After checking out my site it seems I've been using UTF-8 without really realising it, and I'm going to stick with UTF-8. However, when I jump into phpMyAdmin to check out my MySQL tables I run into a few problems. Originally, for my database, the collation was set to latin1_swedish_ci. I have since changed this to utf8_general_ci. This however only affects newly created tables, not the 150 or so tables I currently have which are still latin1_swedish_ci. Do I need to convert the collation of these already existing tables to UTF-8, and if so what's the best method? This takes me to my text editor, NetBeans 7. Do I need to alter anything here, I've not been successful with finding information relating to this? Cheers guys. i am trying to make a range of numbers which have a step of 11 then 7 then 11 which can then be compared. the result im after is 1, 12, 19, 30. Is there a way i could do this without storing the sets in an array and looping though them? Any help would be greatly appreciated, thanks. Hello guys. I'm in need of help. I want to know who to make a full working session. When a player logs in, the session starts. There will be a new button "My Page", he can go there at any time. When he logs off, that button disappears ( Session over ). I'm so bad at explaining stuff. Hope y'all really understood me. This piece of code is used to log the user in: Code: [Select] <?php session_start(); include("config.php"); if(isset($_SESSION["Username"])) { $user = $_SESSION["Username"]; $pass = md5($_SESSION["Password"]); } else { $user = $_POST["User"]; $pass = md5($_POST["Password"]); $_SESSION['Username'] = $user; $_SESSION['Password'] = $pass; $escuser = mysql_real_escape_string($user); $escpass = mysql_real_escape_string($pass); } $result = mysql_query("SELECT * FROM playerinfo WHERE user = '$escuser'"); $num_rows = mysql_num_rows($result); if($num_rows == 0) { echo('That username does not exist...'); echo '<a href="http://yu-ki-ko.com/fsns/""> Go back!</a>'; unset($_SESSION['Username']); unset($_SESSION['Password']); die; } $row = mysql_fetch_row($result); if($row[1] !== $escpass) { echo('Wrong Password!...'); echo '<a href="http://yu-ki-ko.com/fsns/""> Go Back!</a>'; unset($_SESSION['Username']); unset($_SESSION['Password']); die; } ?> Not sure if its working properly or not. I'm stuck at that part. I have a page that processes a variable passed in the url to go get information out of a text file in JSON format. For some reason though, passing one variable loads a page, passing a certain variable (who's data in the file is virtually identical to the first) will cause the browser to just load the page indefinitely. Maybe even more strange is that on my local machine, the variable that won't load is switched, and the other loads fine. How can I debug what's happening when the page never loads so that I never get an error? I am having difficulties with my include_path directives in the php.ini file. Please click the link below to see a screencast of the problem: http://screenr.com/vhY I am very confused as sometimes the include_path does work and sometimes it doesn't work. Also am I allowed to have multiple include_path directives or do I need to include every path in a single include_path directive. I'm playing with this tokenizing autocomplete script but am having a strange issue with it. It all seems to work ok and it's pulling the values over from the php file that's doing the db query ok and if you put in a value that doesn't match it will tell you so, however if you do type in a value that matches it simply disappears. This script is exactly like the demo script except for the paths to the js, css, and php files, and I did remove the 1st example but was having this issue before removing it. No changes made to the js file, php file is identical to the demo just with my own db info and table info put in, and no changes to the css file compared to the demo. I've tried this both with jquery 1.3.0 and 1.4.2 and have the same issue with both. Here is the link to my test page: http://www.erecoverydev.com/autocomplete2/autocomplete.html Here is my js file: http://www.erecoverydev.com/autocomplete2/jquery.tokeninput.js Here is my php code: Code: [Select] <? mysql_pconnect("localhost", "myuser", "mypass") or die("Could not connect"); mysql_select_db("mydb") or die("Could not select database"); $query = sprintf("SELECT cb_activities from jos_comprofiler WHERE cb_activities LIKE '%%%s%%' ORDER BY cb_activities DESC LIMIT 10", mysql_real_escape_string($_GET["q"])); $arr = array(); $rs = mysql_query($query); while($obj = mysql_fetch_object($rs)) { $arr[] = $obj; } echo json_encode($arr); ?> A couple of values that are in my table are web development and kicking cats if you want to test it. Here is the link to the demo: http://loopj.com/tokeninput/demo.html It just doesn't make any sense to me why the demo works and mine doesn't when they are basically identical. Hi everyone! I've been working on a php script to replace links that contain a query with direct links to the files they would redirect to. Hi i have this upload script which works fine it uploads image to a specified folder and sends the the details to the database. but now i am trying to instead make a modify script which is Update set so i tried to change insert to update but didnt work can someone help me out please this my insert image script which works fine but want to change to modify instead Code: [Select] <?php mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("upload") or die(mysql_error()) ; // my file the name of the input area on the form type is the extension of the file //echo $_FILES["myfile"]["type"]; //myfile is the name of the input area on the form $name = $_FILES["image"] ["name"]; // name of the file $type = $_FILES["image"]["type"]; //type of the file $size = $_FILES["image"]["size"]; //the size of the file $temp = $_FILES["image"]["tmp_name"];//temporary file location when click upload it temporary stores on the computer and gives it a temporary name $error =array(); // this an empty array where you can then call on all of the error messages $allowed_exts = array('jpg', 'jpeg', 'png', 'gif'); // array with the following extension name values $image_type = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif'); // array with the following image type values $location = 'images/'; //location of the file or directory where the file will be stored $appendic_name = "news".$name;//this append the word [news] before the name so the image would be news[nameofimage].gif // substr counts the number of carachters and then you the specify how how many you letters you want to cut off from the beginning of the word example drivers.jpg it would cut off dri, and would display vers.jpg //echo $extension = substr($name, 3); //using both substr and strpos, strpos it will delete anything before the dot in this case it finds the dot on the $name file deletes and + 1 says read after the last letter you delete because you want to display the letters after the dot. if remove the +1 it will display .gif which what we want is just gif $extension = strtolower(substr($name, strpos ($name, '.') +1));//strlower turn the extension non capital in case extension is capital example JPG will strtolower will make jpg // another way of doing is with explode // $image_ext strtolower(end(explode('.',$name))); will explode from where you want in this case from the dot adn end will display from the end after the explode $myfile = $_POST["myfile"]; if (isset($image)) // if you choose a file name do the if bellow { // if extension is not equal to any of the variables in the array $allowed_exts error appears if(in_array($extension, $allowed_exts) === false ) { $error[] = 'Extension not allowed! gif, jpg, jpeg, png only<br />'; // if no errror read next if line } // if file type is not equal to any of the variables in array $image_type error appears if(in_array($type, $image_type) === false) { $error[] = 'Type of file not allowed! only images allowed<br />'; } // if file bigger than the number bellow error message if($size > 2097152) { $error[] = 'File size must be under 2MB!'; } // check if folder exist in the server if(!file_exists ($location)) { $error[] = 'No directory ' . $location. ' on the server Please create a folder ' .$location; } } // if no error found do the move upload function if (empty($error)){ if (move_uploaded_file($temp, $location .$appendic_name)) { // insert data into database first are the field name teh values are the variables you want to insert into those fields appendic is the new name of the image mysql_query("INSERT INTO image (myfile ,image) VALUES ('$myfile', '$appendic_name')") ; exit(); } } else { foreach ($error as $error) { echo $error; } } //echo $type; ?> I'm having trouble echoing $year in my script. Listed below is the script, just below ,$result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error());, in the script I try to echo $year. It doesn't show up in the table on the webpage. Everything else works fine. Any help wold be appreciated greatly. Thanks in advance. <?php include 'config2.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; echo "<table align=center border=1>"; echo "<br>"; echo "<tr>"; echo "<td align=center>"; ?> <div style="float: center;"><a><h1><?php echo $year; ?></h1></a></div> <?php echo "</td>"; echo "</tr>"; echo "</table>"; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 2; echo "<table align=center>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div style="float: left;"> <div><img src="<?php echo $image1; ?>"></div> </div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> </table> Hello, I stored a fsockopen function in a separate "called.php" file, in order to run it as another thread when it needs. The called script should return results to the "master.php" script. I'm able to run the script to get the socket working, and I'm able to get results from the called script. I tried for hours but I can't do the twice both My master.php script (with socket working): Code: [Select] <?php $command = "(/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR] &) > /dev/null"; $result = exec($command); echo ("result = $result\r\n"); ?> and my called.php script Code: [Select] #!/mnt/opt/usr/bin/php-cli -q <?php $device = $_SERVER['argv'][1]; $port = "8080"; $fp = fsockopen($device, $port, $errno, $errstr, 5); fwrite($fp, "test"); fclose($fp); echo ("normal end of the called.php script"); ?> In the master script, if I use Code: [Select] $command = "(/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR] &) > /dev/null"; the socket works, but I have nothing in $result (note also that I don't anderstand why the ( ... &) are needed!?) and if I use Code: [Select] $command = "/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR]"; I have the correct text "normal end of the called.php script" in $result but the socket connection is not performed (no errors in php logs) Could you help me to find a way to let's work the two features correctly together? Thank you. hey guys im really just after a bit of help/information on 2 things (hope its in the right forum).
1. basically I'm wanting to make payments from one account to another online...like paypal does...im wondering what I would need to do to be able to do this if anyone can shine some light please?
2.as seen on google you type in a query in the search bar and it generates sentences/keywords from a database
example:
so if product "chair" was in the database
whilst typing "ch" it would show "chair" for a possible match
I know it would in tale sql & json but im after a good tutorial/script of some sort.
if anyone can help with some information/sites it would be much appreciated.
Thank you
I'm trying to use this script known as SimpleImage.php that can be found here <a href="http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php">link</a> I'm trying to include what is on the bottom of the page to my existing script can anyone help me I've tried several ways but its not working. Code: [Select] <?php session_start(); error_reporting(E_ALL); ini_set('display_errors','On'); //error_reporting(E_ALL); // image upload folder $image_folder = 'images/classified/'; // fieldnames in form $all_file_fields = array('image1', 'image2' ,'image3', 'image4'); // allowed filetypes $file_types = array('jpg','gif','png'); // max filesize 5mb $max_size = 5000000; //echo'<pre>';print_r($_FILES);exit; $time = time(); $count = 1; foreach($all_file_fields as $fieldname){ if($_FILES[$fieldname]['name'] != ''){ $type = substr($_FILES[$fieldname]['name'], -3, 3); // check filetype if(in_array(strtolower($type), $file_types)){ //check filesize if($_FILES[$fieldname]['size']>$max_size){ $error = "File too big. Max filesize is ".$max_size." MB"; }else{ // new filename $filename = str_replace(' ','',$myusername).'_'.$time.'_'.$count.'.'.$type; // move/upload file $target_path = $image_folder.basename($filename); move_uploaded_file($_FILES[$fieldname]['tmp_name'], $target_path); //save array with filenames $images[$count] = $image_folder.$filename; $count = $count+1; }//end if }else{ $error = "Please use jpg, gif, png files"; }//end if }//end if }//end foreach if($error != ''){ echo $error; }else{ /* -------------------------------------------------------------------------------------------------- SAVE TO DATABASE ------------------------------------------------------------------------------------ -------------------------------------------------------------------------------------------------- */ ?> Well the subject line is pretty explicit. I found this script that uploads a picture onto a folder on the server called images, then inserts the the path of the image on the images folder onto a VACHAR field in a database table. Code: [Select] <?php //This file inserts the main image into the images table. //address error handling ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); //authenticate user //Start session session_start(); //Connect to database require ('config.php'); //Check whether the session variable id is present or not. If not, deny access. if(!isset($_SESSION['id']) || (trim($_SESSION['id']) == '')) { header("location: access_denied.php"); exit(); } else{ // Check to see if the type of file uploaded is a valid image type function is_valid_type($file) { // This is an array that holds all the valid image MIME types $valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif"); if (in_array($file['type'], $valid_types)) return 1; return 0; } // Just a short function that prints out the contents of an array in a manner that's easy to read // I used this function during debugging but it serves no purpose at run time for this example function showContents($array) { echo "<pre>"; print_r($array); echo "</pre>"; } // Set some constants // This variable is the path to the image folder where all the images are going to be stored // Note that there is a trailing forward slash $TARGET_PATH = "images/"; // Get our POSTed variable $image = $_FILES['image']; // Sanitize our input $image['name'] = mysql_real_escape_string($image['name']); // Build our target path full string. This is where the file will be moved to // i.e. images/picture.jpg $TARGET_PATH .= $image['name']; // Make sure all the fields from the form have inputs if ( $image['name'] == "" ) { $_SESSION['error'] = "All fields are required"; header("Location: member.php"); exit; } // Check to make sure that our file is actually an image // You check the file type instead of the extension because the extension can easily be faked if (!is_valid_type($image)) { $_SESSION['error'] = "You must upload a jpeg, gif, or bmp"; header("Location: member.php"); exit; } // Here we check to see if a file with that name already exists // You could get past filename problems by appending a timestamp to the filename and then continuing if (file_exists($TARGET_PATH)) { $_SESSION['error'] = "A file with that name already exists"; header("Location: member.php"); exit; } // Lets attempt to move the file from its temporary directory to its new home if (move_uploaded_file($image['tmp_name'], $TARGET_PATH)) { // NOTE: This is where a lot of people make mistakes. // We are *not* putting the image into the database; we are putting a reference to the file's location on the server $sql = "insert into images (member_id, image_cartegory, image_date, image) values ('{$_SESSION['id']}', 'main', NOW(), '" . $image['name'] . "')"; $result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error()); header("Location: images.php"); echo "File uploaded"; exit; } else { // A common cause of file moving failures is because of bad permissions on the directory attempting to be written to // Make sure you chmod the directory to be writeable $_SESSION['error'] = "Could not upload file. Check read/write persmissions on the directory"; header("Location: member.php"); exit; } } //End of if session variable id is not present. ?> The script seems to work fine because I managed to upload a picture which was successfully inserted into my images folder and into the database. Now the problem is, I can't figure out exactly how to write the script that displays the image on an html page. I used the following script which didn't work. Code: [Select] //authenticate user //Start session session_start(); //Connect to database require ('config.php'); $sql = mysql_query("SELECT* FROM images WHERE member_id = '".$_SESSION['id']."' AND image_cartegory = 'main' "); $row = mysql_fetch_assoc($sql); $imagebytes = $row['image']; header("Content-type: image/jpeg"); print $imagebytes; Seems to me like I need to alter some variables to match the variables used in the insert script, just can't figure out which. Can anyone help?? I have an application which runs on more than one server and need to launch one PHP script from another PHP script. Since this is different than a function call I'm not sure how it's done. I plan to include parameters in the URL I send and use GETs to pick up parameters in the "called" PHP script. Thanks for sugestions How would I go about making it to where,, I can tell the script to use a certain extension of php in the script like curl.. ? Thanks Hi, I am trying to run two scripts on one page. When I use just one script on the page they work however when I place both scripts on the same page one of them disrupts the other script. This script prevents the other following script from working: Code: [Select] ini_set('display_errors', 1); error_reporting(-1); { $query = "SELECT * FROM answers ORDER BY `aid` DESC LIMIT 0, 11"; } $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $answer = $row['answer']; $aid = $row['aid']; echo " <div class='questionboxquestion'> <a href= 'http://www.domain.co.uk/test/easy/answer.php?aid=$aid' class='questionlink'>$answer</a> </div> <div class='questionboxnotes'> </br> </div> <div class='questionboxlinks'> <div class='questionboxcategory'> <div class='questionboxcategorytitle'> Category: </div> <a href= 'http://www.domain.co.uk/test/easy/furniture-category.php' class='questionanswerlink'></a> </div> <div class='questionboxanswerlink'> <a href= 'http://www.domain.co.uk/test/oeasy/index.php' class='questionanswerlink'>Answer</a> </div> </div> "; } Code: [Select] <?php if($error) echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />"; ?> <label for="username">Username: </label> <input type="text" name="username" value="<?php if($_POST['username']) echo $_POST['username']; ?>" /><br /> <label for="password">Password: </label> <input type="password" name="password" value="<?php if($_POST['password']) echo $_POST['password']; ?>" /><br /> <label for="password2">Retype Password: </label> <input type="password" name="password2" value="<?php if($_POST['password2']) echo $_POST['password2']; ?>" /><br /> <label for="email">Email: </label> <input type="text" name="email" value="<?php if($_POST['email']) echo $_POST['email']; ?>" /><br /><br /> <input type="submit" name="submit" value="Register" /> I cant figure out why my log out script doesnt work all you need is session_start(); session_destroy(); right? here is my script to keep people loged in which works fine. Code: [Select] if ($_SESSION['login_time'] < strtotime('-60 minutes')) { header("Location: signup.php"); exit(); session_destroy(); 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: Code: [Select] <?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: Code: [Select] <?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: Code: [Select] $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 |