Jump to content

dannyone

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Everything posted by dannyone

  1. Hey, i have used phpmyadmin and my query works fine and displays all the correct records. however now i am trying to show them in html and its seems that it isn't storing some of the values i am selecting. il show you my code so i can explain better $days = array('mon' => '', 'tue' => '', 'wed' => '', 'thu' => '', 'fri' => ''); // Add our list of days to our time slots $times = array( '9-10' => $days, '10-11' => $days, '11-12' => $days, '12-1' => $days, '1-2' => $days, '2-3' => $days, '3-4' => $days); // Connect to DB and run our query $sql = new mysqli('localhost', 'danny', 'danny', 'tutorial'); $run = $sql->query("SELECT Marker_Rooms.Room_ID2, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '101' AND Marker_Rooms.Room_ID = Rooms_Free.Room_ID AND Rooms_Free.status = '0' UNION SELECT Marker_Rooms.Room_ID1, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '101' AND Marker_Rooms.Room_ID1 = Rooms_Free.Room_ID AND Rooms_Free.status = '0' UNION SELECT Marker_Rooms.Room_ID2, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '101' AND Marker_Rooms.Room_ID2 = Rooms_Free.Room_ID AND Rooms_Free.status = '0'"); while($row = $run->fetch_object()) { $times[$row->timeslot][$row->day] = "<input type=radio name=radio[] id=radio[] value= $row->id/> $row->Room_ID <br> <input type=radio name=radio[] id=radio[] value= $row->id/> $row->Room_ID1 <br> <input type=radio name=radio[] id=radio[] value= $row->id/> $row->Room_ID2"; //////////////////////////////////////////////////////////////// above is my problem! } $body = <<< endBody <center> <table align="center" border="1" cellspacing="0" cellpadding="1"> <tr> <th align="center">Time</th> <th align="center">Monday</th> <th align="center">Tuesday</th> <th align="center">Wednesday</th> <th align="center">Thursday</th> <th align="center">Friday</th> </tr> endBody; // For each time slot, check each day for a value // If one exists, display it, if not, display an empty table data (<td>) foreach($times as $timeslot => $day) { $body .= "\n\t\t<tr>\n\t\t\t<td>$timeslot</td>"; foreach($day as $course) { $td = (strlen($course) > 0) ? $course : ' '; $body .= "\n\t\t\t<td>$td</td>"; } $body .= "\n\t\t</tr>"; } $body .= "\n\t</table>\n</center"; ?> <?=$body?> i am trying to show all the Room_ID's with a radio button that have status 0. however it doesn't work, it just show Room_ID, not Room_ID1 or Room_ID2. i have tried just using Room_ID1 and nothing appears so i guess im not selecting it properly. does any1 have any ideas? Thanks
  2. ok i have sorted it now thanks anyways
  3. hello everyone i have a problem, i have got 3 working querys, to show on seperate tables, however i need to either combine these 3 querys to show all the information in one table, or i need to run the querys straight after each other so i can do it. my aim is to show a table of all the times that are available for 3 selected rooms. the 3 querys i have work , seperatly, but i dont know how to join them. can any one help here are my 3 working querys "SELECT Marker_Rooms.Room_ID, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '" .$_SESSION['login'] . "' AND Marker_Rooms.Room_ID = Rooms_Free.Room_ID AND Rooms_Free.status = '0'" SELECT Marker_Rooms.Room_ID1, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '" .$_SESSION['login'] . "' AND Marker_Rooms.Room_ID1 = Rooms_Free.Room_ID AND Rooms_Free.status = '0'" "SELECT Marker_Rooms.Room_ID2, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '" .$_SESSION['login'] . "' AND Marker_Rooms.Room_ID2 = Rooms_Free.Room_ID AND Rooms_Free.status = '0'" Here is a query i tried but it just displays all records in the table regardless is they have status 0 or not. "SELECT Marker_Rooms.Room_ID, Marker_Rooms.Room_ID1, Marker_Rooms.Room_ID2, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE (Marker_Rooms.Room_ID = Rooms_Free.Room_ID AND Marker_Rooms.Marker_ID = '" .$_SESSION['login'] . "' AND Rooms_Free.status = '0') OR (Marker_Rooms.Room_ID1 = Rooms_Free.Room_ID AND Marker_Rooms.Marker_ID = '" .$_SESSION['login'] . "' AND Rooms_Free.status = '0') OR (Marker_Rooms.Room_ID2 = Rooms_Free.Room_ID AND Marker_Rooms.Marker_ID = '" .$_SESSION['login'] . "' AND Rooms_Free.status = '0')" any help would be fantastic Thanks
  4. thanks maq, i saved it in a session and it worked an absolute treat!!
  5. i have created a dynamic dropdown from my mysql database, and the value selected is posted to a new page, as follows $room = $_POST['room']; now i can use that value on the other page to collect more information from my database. however i now need to post that value again, this time into my database using an update query, but when i press submit it looses the value and looses all the information linked to it on the page. is there a way of reposting the value? or another way round this? im seriously confused can any1 help? Thanks
  6. ok iv managed to do it now.. thanks every1 for their help. i just couldn't get my head around it at first! i have another question tho, once i have updated the database, i want to query the database again and disable tick the rows were status = 1, so that users can view them but not edit them. is there a simple solution? thanks
  7. i have been trying to use the tutorial from the php freaks tutorial for checkboxes and for some reason it wont work. i have created the tables properly and it connects to my database, however it wont select any of my data from the database does anyone know why? thanks
  8. i havn't redarrow, hope you don't mind but how do i use that? thanks
  9. Thanks again Brian. i have tried using your code but i just couldn't get my head around it, im not that good with php/mysql. i have been reading up and i have this now, but the problem is it updates all the records to which room is selected. i just want it to update the checkbox selected, can any1 advise me how i would this? <html> <body> <form method="post" action="<?php echo $PHP_SELF;?>"> <?php mysql_connect("localhost", "danny", "danny") or die("Connection Failed"); mysql_select_db("tutorial")or die("Connection Failed"); ?> <br> <?php $car = $_POST['car']; mysql_connect("localhost", "danny", "danny") or die(mysql_error()); echo "Connected to MySQL<br />"; mysql_select_db("tutorial") or die(mysql_error()); echo "Connected to Database<br /><br />"; $result1 = mysql_query("UPDATE test SET status='$car' WHERE status='0' AND Room_ID='101'") or die(mysql_error()); $query = "SELECT * FROM test WHERE Room_ID = '101'"; $result = mysql_query($query); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { ?> <input type="checkbox" name="car" value="1"><?php echo $line[day], $line[timeslot], $line[Room_ID]?> <br> <?php if ($_POST['car']=="1") { echo "YES<br>"; } else { echo "NO<br>"; } } ?> </body> </html> <input type="submit" value="submit" name="submit"> <br /> <br /> </form> </html> </form> </table> </form> </html> my db is room_id, timeslot, day, status 1 9-10 Monday 0 the select statement works and shows all the correct room details and checkboxes, but when i click on 1 checkbox it updates the status of all of them. do i need a foreach loop or something? thanks
  10. yeah sorry these are the checkboxes i was using <body> <table width="200" border="1"> <tr> <td> </td> <td>09:00</td> <td>10:00</td> <td>11:00</td> <td>12:00</td> <td>13:00</td> <td>14:00</td> <td>15:00</td> </tr> <tr> <td><div align="center">Monday</div></td> <td> <div align="center"> <input type="checkbox" name="Monday910[][]" value="whatever" /> </div> </form> </td> <td><div align="center"> <input type="checkbox" name="Monday1011[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Monday1112[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Monday121[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Monday12[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Monday23[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Monday34[][]" value="whatever" /> </div></td> </tr> <tr> <td><div align="center">Tuesday</div></td> <td><div align="center"> <input type="checkbox" name="Tuesday910[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Tuesday1011[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Tuesday1112[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Tuesday121[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Tuesday12[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Tuesday23[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Tuesday34[][]" value="whatever" /> </div></td> </tr> <tr> <td><div align="center">Wednesday</div></td> <td><div align="center"> <input type="checkbox" name="Wednesday910[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Wednesday1011[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Wednesday1112[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Wednesday121[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Wednesday12[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Wednesday23[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Wednesday34[][]" value="whatever" /> </div></td> </tr> <tr> <td><div align="center">Thursday</div></td> <td><div align="center"> <input type="checkbox" name="Thursday910[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Thursday1011[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Thursday1112[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Thursday121[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Thursday12[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Thursday23[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Thursday34[][]" value="whatever" /> </div></td> </tr> <tr> <td><div align="center">Friday</div></td> <td><div align="center"> <input type="checkbox" name="Friday910[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Friday1011[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Friday1112[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Friday121[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Friday12[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Friday23[][]" value="whatever" /> </div></td> <td><div align="center"> <input type="checkbox" name="Friday34[][]" value="whatever" /> </div></td> </tr> </body> im not sure how im going to work them though thanks
  11. ok il try to explain the best i can. i have a drop down list which i can choose a room from. once i have chosen the room i then want to be able to choose times from a list of checkboxes and update the records in my database. The checkboxes will be in a table like mon tue wed 9 checkbox checkbox 10 checkbox 11 etc... i simply want to update 1 field in my db from 0 to 1, when that checkbox is ticked. my db looks like room, time, day, int 1 9 M 0 i want the rooms details selected in the dropdown to be updated so that int would change to 1. so room, time, day, int 1 9 M 1 i have all the fields in the database and i can do the dropdown, but i havent got a clue with the checkboxs and updating the db. i had help previously to insert the data into a db using mulit dimensional arrays, but its not the right design for this page i have, i just need to update a field. any help would be great Thanks
  12. hello everyone i have a rather complex query that i am trying to make but i just can't figure out how im going to do it, here is my table structure Marker_Free table Marker_ID, timeslot, day, status Marker_Rooms table Marker_ID, Room_ID Rooms_Free table Room_ID, timeslot, day, status now what i need to do is compare all the data in these tables and show them in a html table. i have attempted to do the query and i can get it to display the room availability for tht user, but i also want it to show that markers availability on the same table. i have two seperate querys that do these, but i need to make them into 1 so i can show all the results. can some1 have a look and try and help me combine the queries so that it works. any help would be greatly appreciated! this code displays Room availability for the user "SELECT Mf.Marker_ID, Mf.timeslot, Mf.day, Mf.Status, Rf.Room_ID, Rf.timeslot, Rf.day, Rf.status, Mr.Marker_ID, Mr.Room_ID FROM Marker_Free AS Mf INNER JOIN Marker_Rooms AS Mr ON (Mf.Marker_ID = Mr.Marker_ID) INNER JOIN Rooms_Free AS Rf ON (Mr.Room_ID = Rf.Room_ID) WHERE Mf.Marker_ID = '" .$_SESSION['login'] . "'"); this code displays that Markers availability "SELECT Marker_ID, timeslot, day, Status FROM Marker_Free WHERE Marker_ID = '" .$_SESSION['login'] . "'"); Thanks in advance!
  13. thanks for the reply Maq, i have tried using your code and modifying to match my data but it doesn't seem to work it just gives me a blank page. do i need to add more detail into it to get it to work? <?php $user = $_SESSION['login']; mysql_connect("localhost", "xx", "xx") or die(mysql_error()); mysql_select_db("xx") or die(mysql_error()); $result = myql_query("SELECT * FROM Marker_Rooms WHERE Marker_ID = '$user'") or die(mysql_error()); if(mysql_num_rows($result) > 0) { echo "sorry, you're already in the DB"; } else { echo "not in the DB, do whatever you want in this block"; } ?> im already calling session further up so not included it here thanks
  14. hello, im wondering if there is a way to do this. i have a page where users can select from a few drop downs some values and save them into a db. is there a way to create a query were if the user exists in the db then they can not use that page? im storing the user_id in a session. any help would be greatly appreciated. thanks
  15. iv been working on this for a bit now since the last comment and iv got a little further. when i echo the value now it always shows the last value that is been called from the mysql table. can some1 help and just see were im going wrong please, im really stuck <form method="post" action="<?php echo $PHP_SELF;?>"> <body> <?php mysql_connect("localhost", "xx", "xx") or die(mysql_error()); echo "Connected to MySQL<br />"; mysql_select_db("xx") or die(mysql_error()); "<br/>"; echo "Connected to Database"; "<br>"; "<br>"; $query=("select Room_ID, RoomName from Rooms ORDER BY Room_ID"); $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); while($row=mysql_fetch_array($result)){ $category = $row["Room_ID"]; "<br/>"; "<br/>"; echo "<input type=\"checkbox\" name=\"category[]\" value=\"\"> $category:"; echo "<br>"; } echo "".$category.""; ?> <input type="submit" value="submit" name="submit"> <br /> <br /> </form> </html> thanks
  16. thanks everyone for the replys, i have tried using print_r($_POST) and it gives me this; Array ( [room] => [submit] => Select Availability ) what does this mean? im guessing its not storing the value? thanks
  17. thanks everyone for the replys i have tried using your answer taquitosensel but it still doesn't echo anything. and i have also tried yesideez solution but that just gives me a blank screen? is there anything else i could try? thanks again for the help guys its must appreciated! thanks
  18. hello everyone i am creating a list of dynamic checkboxes that are been pulled from my mysql db. i can get them to display correctly, but i want to simply echo the value that the user has selected. but atm its not displaying anything. can some1 help please, heres my code <?php require_once('auth1.php'); require_once('config.php'); ?> <html> <form method="post" action="<?php echo $PHP_SELF;?>"> <?php $room = $_POST['room']; mysql_connect("localhost", "xx", "xx") or die(mysql_error()); mysql_select_db("xx") or die(mysql_error()); //$query=("select * from categories"); $result = mysql_query("SELECT * FROM Rooms") or die(mysql_error()); while($row=mysql_fetch_array($result)){ echo "<input type='checkbox' value='' name='room' />$row[Room_ID]<br/> "; } // this will display all checkboxes w/ values in db. echo $_POST['room']; ?> <input type="submit" value="Select Availability" name="submit"> </form> </html> on submit i would like the rooms they have selected just to be echo'd on the screen thanks again
  19. iv got a bit of it working however can some1 advise me of a way so that i can store the value the user has selected from the drop down into a array so i can save it to my mysql db <?php $row = $_POST['Room_ID']; if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form ?> <form method="post" action="<?PHP_SELF;?>"> <SELECT NAME="Room_ID"> <option value="Room_ID" SELECTED>Select A Room</option> <?php mysql_connect("localhost", "danny", "danny", "tutorial") or die(mysql_error()); echo "Connected to MySQL<br />"; mysql_select_db("tutorial") or die(mysql_error()); echo "Connected to Database"; $result = mysql_query ("SELECT Room_ID FROM Rooms"); if ($row = mysql_fetch_array($result)) { do { print ("<OPTION VALUE=\"".$row['Room_ID']."\">"); print $row['Room_ID']; print ("</OPTION>"); } while($row = mysql_fetch_array($result)); } else { mysql_connect("localhost", "danny", "danny") or die("Could not connect: " . mysql_error()); mysql_select_db("tutorial"); $query = "INSERT INTO Rooms_Free (Room_ID) VALUES ()"; $result = mysql_query($query); }} echo $_POST['Room_ID'] ; ?> <input type="submit" value="submit" name="submit"> </select> </form> i just dont know what to use in the VALUES section to get it to enter. the echos work but they wont enter into the db... can some1 please help Thanks
  20. Thanks rhodesa for the quick reply. i tried using the code you gave me but it just gives me a blank screen now? is there anything else im missing? Thanks
  21. hello everyone can someone please help with this i have this page where i am submitting a dropdown and then some checkboxs to a mysql table. the code is working and inserting nicely, but its taking the last value from the drop down and inserting that one instead of the value i have selected?! could someone please point out where i am going wrong im rather puzzled! thanks <?php $row = $_POST['Room_ID']; if (!isset($_POST['submit'])) { ?> <html> <head> <title>Student Timetable</title> </head> <body> <form method="post" action="<?php echo $PHP_SELF;?>"> Select a Student:<br /> <?php //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } echo'<select name="Room_ID">'; $res=mysql_query("select Room_ID from Rooms"); if(mysql_num_rows($res)==0) echo "there is no data in table.."; else echo "<option>--SELECT ROOM--</option>"; for($i=0;$i<mysql_num_rows($res);$i++) { $row=mysql_fetch_assoc($res); echo"<option>$row[Room_ID]</option>"; } echo'</select>'; ?> <input type="submit" value="submit" name="submit"> <br /><br /> </form> <? }else{ echo "" .$row. ""; } ?> <? if (!isset($_POST['submit1'])) { // if page is not submitted to itself echo the form ?> <html> <head> <title>Personal INFO</title> </head> <body> <form method="post" action="<?php echo $PHP_SELF;?>"> <input type="checkbox" name="media[]" value="Poster" />Poster<br /> <input type="checkbox" name="media[]" value="Website" />Website<br /> <input type="checkbox" name="media[]" value="Magazine" />Magazine<br /> <input type="submit" value="submit1" name="submit1"> </form> <? } else { mysql_connect("localhost", "danny", "danny") or die("Could not connect: " . mysql_error()); mysql_select_db("tutorial"); $media_array = $_POST['media']; foreach ($media_array as $one_media) { $source .= $one_media.", "; } $media = substr($source, 0, -2); $query = "INSERT INTO Rooms_Free (Room_ID, timeslot) VALUES( '$row[Room_ID]' ,'$media')"; $result = mysql_query($query); } ?> im using $row[Room_ID] to store the value they have selected. thanks
  22. thanks alot for your help keith. i have been trying to use your code but it will not work for me. it just shows a blank screen with no output. sorry to be a pain but could you please explain the 2nd half of your code again to me please from; } else { if (!isset($_POST['submit2'])) { ?> <html> <head> <title>Student Timetable</title> </head> <body> <form method="post" action="<?php echo $PHP_SELF;?>"> Select a Student:<br /> <?php echo "<input type='hidden' name='Room_ID' value='$nt' />"; echo "Your are view the availability or Room ID ".$nt.":<br /><br /><br />"; echo "9:00-12:00 <input type='checkbox' name='Time1' value='1' /><br />"; echo "12:00-17:00 <input type='checkbox' name='Time2' value='1' /><br />"; ?> <input type="submit" value="submit2" name="submit2"> <br /><br /> </form> <? } else { // Process 2nd submit button } } ?> hopefully i will understand php properly soon and be able to get things better thanks again
  23. yeah you got the right idea keith. i need a way for a user to be able to select a room from a drop down, then once the form has been posted, be able to select times that are free for that particular room using checkboxes. you helped me previously with the multidimensional arrays, that i am using again on this page to store the times selected. however if i post the value from the dropdown it stores in the database fine, but if i submit the checkbox arrays its just ignores the $nt['Room_ID'] and just stores the room as 0. can you show me how i would use the hidden field in the code below please, as i haven't got a clue how it would work <?php $nt=$_POST['Room_ID']; if (!isset($_POST['submit'])) { ?> <html> <head> <title>Student Timetable</title> </head> <body> <form method="post" action="<?php echo $PHP_SELF;?>"> Select a Student:<br /> <?php //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } $query=("SELECT Rooms.Room_ID,Rooms.RoomName,Rooms.Building FROM Rooms"); $result = mysql_query ($query); echo "<select name=Room_ID value=''>Room_ID</option>"; // printing the list box select command echo "<option>- Please Select Room -</option>\n"; while($nt=mysql_fetch_array($result)){ echo "<option value=$nt[Room_ID]>$nt[Room_ID], $nt[RoomName] $nt[building]</option>"; "<br />"; } echo "</select>";// Closing of list box ?> <input type="submit" value="submit" name="submit"> <br /><br /> </form> <? }else{ echo "Your are view the availability or Room ID ".$nt.":<br /><br /><br />"; } ?> when i come to use the $nt / Room_ID later on to be stored in the database along with other information, would i use '$nt' or $_POST['Room_ID']? thanks for the help again
  24. thanks keith, sorry if this sounds thick but how would i use hidden fields in the dynamic drop down? its just the examples i have seen all use examples like <input type="hidden" name="hidfield" value="Cart ID "> but i am collecting my information from a database as the Room_ID can change due to adding/removing rooms etc.. thanks
  25. sorry i didnt make myself very clear in my previous post. can some1 help me extend the code i have, currently i am selecting the Room_ID, Name and building from a table called Rooms, and i want to store the selected value as a session so that i can use it with some checkboxes. here is the code i have, <?php $nt=$_POST['Room_ID']; if (!isset($_POST['submit'])) { ?> <html> <head> <title>Student Timetable</title> </head> <body> <form method="post" action="<?php echo $PHP_SELF;?>"> Select a Student:<br /> <?php //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } $query=("SELECT Rooms.Room_ID,Rooms.RoomName,Rooms.Building FROM Rooms"); $result = mysql_query ($query); echo "<select name=Room_ID value=''>Room_ID</option>"; // printing the list box select command echo "<option>- Please Select Room -</option>\n"; while($nt=mysql_fetch_array($result)){ echo "<option value=$nt[Room_ID]>$nt[Room_ID], $nt[RoomName] $nt[building]</option>"; "<br />"; } echo "</select>";// Closing of list box ?> <input type="submit" value="submit" name="submit"> <br /><br /> </form> <? }else{ echo "Your are view the availability or Room ID ".$nt.":<br /><br /><br />"; } ?> all the code works fine but is there a way that i can save $nt as a sessions so that i can use it with some checkboxes once the form has been posted? Thanks
×
×
  • 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.