Jump to content

almystersv

Members
  • Posts

    105
  • Joined

  • Last visited

    Never

Everything posted by almystersv

  1. Hi Guys I have this page that I am trying to use to remove one item at a time from the array. At present it just competely empties the array. Please help... <?php session_start(); foreach($_SESSION['basket'] as $key => $product) { if ($_SESSION['basket'][$key]['URN'] == $product['URN']) { unset($_SESSION['basket'][$key]); } } header("Location: StationaryMain.php"); exit(); ?>
  2. ...any idea on how i get it from removing all products in the shopping basket to just one!?
  3. Superb. Sorry for having to explain so simply for me! Legend!
  4. Hi Ive changed the code so now it empties the whole basket but not the products individually... <?php session_start(); foreach($_SESSION['basket'] as $key => $product) { if ($_SESSION['basket'][$key]['URN'] == $product['URN']) { unset($_SESSION['basket'][$key]); } } header("Location: StationaryMain.php"); exit(); ?> It does now get to the IF Statement though.
  5. Hi, I commented out the header("Location: StationaryMain.php"); exit(); part of my code so it didnt keep returning to that page and input that piece of code u gave me that would output a message but no message appeared, so i take it it isn't getting to the if statement!
  6. Ok, still don't really understand how to get the variables from there into the array but thank you for your time!
  7. This made no difference. And Im not entirely sure how to echo an array to the screen...!? Thanks for your help.
  8. Hi Guys, I have this table in place that looks at the previous messages that have been left by other users. At the moment is automatically sorted by date. But I was wondering if it was possible to allow the user to click on the header of each column which would then sort the table by that column. For example... If it had the headings Date, username, Input Type etc.. then if they were to click on the heading Input Type it would sort all the records in that table by the input type! Here is my code for the message page... <?php session_start(); if (isset($_SESSION['username']) == false){ header("Location: login.php"); exit(); } require "connect.php"; ?> <!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>BIS Portal</title> </head> <body> <?php include ("header.php"); ?> <p>Messages</p> </h2> <table align="right" border="1" name="Messages Table" id="1" tabindex="1" color ="#1E1EC8" width="100%"> <tr> <th width="8%" align="left" ><h3>Message Number</h3></th> <th width="21%" align="left" ><h3>Title</h3></th> <th width="42%" align="left" ><h3>Content</h3></th> <th width="15%" align="left" ><h3>Date</h3></th> <th width="14%" align="left" ><h3>User</h3></th> </tr> <?php $query = "SELECT * FROM message, employee WHERE message.empID = employee.empID ORDER BY messageID"; $result = mysql_query($query, $connection) or die ("MySQL Error: ".mysql_error()); while($row = mysql_fetch_array($result)) { ?> <tr> <td align="center"><?php echo $row['messageID']?></td> <td><?php echo $row['msgTitle']?></td> <td><?php echo $row['msgBody']?></td> <td><?php echo $row['msgDate']?></td> <td><?php echo $row['fName']?> <?php echo $row['sName']?></td> </tr> <?php } ?> </table> </h4> </body> </html> Cheers
  9. Hi Guys, I want my page to display all the previous orders made and the relevant details. It does do this at the moment but it repeats the order number with every product it shows. Ideally I want to have the order number just once, then all the products related to that order listed below. Would also like the price of all the products to be added up into a total but havent looked into that yet. Help with either would be great Here is my past orders page... <?php session_start(); if (isset($_SESSION['username']) == false){ header("Location: login.php"); exit(); } require "connect.php"; ?> <!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>BIS Portal</title> </head> <body> <?php include ("header.php"); ?> <h4> <table width="100%" border="1"> <tr> <th width="8%">Order Number</th> <th width="30%">Products</th> <th width="10%">Price</th> <th width="14%">Date</th> <th width="13%">User</th> <th width="30%">Status</th> </tr> <?php $query = "SELECT * FROM orders o, productorder e, product p, employee y WHERE o.orderID = e.orderID AND p.URN = e.URN AND y.empID = o.empID"; $result = mysql_query ($query, $connection) or die ("Unable to perform query<br>$query"); while($row = mysql_fetch_array($result)) { ?> <tr> <td><?php echo $row['orderID']?></td> <td><?php echo $row['productName']?></td> <td><?php echo $row['price']?></td> <td><?php echo $row['date']?></td> <td><?php echo $row['fName']?><?php echo $row['sName']?></td> <td><?php echo $row['status']?></td> </tr> <?php } ?> </table> </h4> </body> </html>
  10. hi, Thanks for taking a look. I tried your suggestion but it has made no difference!
  11. Hi Guys, Im creating a mock up of a stationary ordering system and have the add to basket function working fine but the remove from basket is not working. Here is my code for removing items from the shopping basket.. <?php session_start(); foreach($_SESSION['basket'] as $key => $product) { if ($_SESSION['basket'][$key]['URN'] == $_GET['URN']) { unset($_SESSION['basket'][$key]); } } header("Location: StationaryMain.php"); exit(); ?> Any help on this would be brilliant, thanks
  12. Superb, Thanks! Any chance of adding a link that pops up when it goes over 3?! So say 4 things are added, it will only show the top 3 but then a little link at the bottom will appear saying more... Which when click will jst link to the basket page. Thanks
  13. Hi Guys, I am creating a mock up of a stationary ordering system and have a side bar on main products page that shows a snippet of the shopping basket and i want it to show just the top three items in the basket. Here is my code that displays the basket on my products page... <?php if (isset ($_SESSION['basket'])) { foreach($_SESSION['basket'] as $key => $product) { ?> <tr> <td width="40%"><?php echo $_SESSION['basket'][$key]['productName']?></td> <td width="20%">£<?php echo $_SESSION['basket'][$key]['price']?></td> <td width="20%" align="center"><?php echo $_SESSION['basket'][$key]['quantity']?></td> <td><a href="removefrombasket.php?URN=<?php echo $product['URN']?>">[-]</a></td> </tr> <?php } ?> </table> <?php } else { ?> No Products Chosen. <?php } ?> the reason for this is that i have limited space and at current everytime something is added it keeps displaying it on this page, understandably, but I would like to know how I can change it to show just 3. Thanks
  14. ??? Sorry. But isnt that just going to pre-fill the textbox with the title of the user that is currently logged in?!
  15. Hello, Correct me if i have misunderstood your solution, but i do not want the text box to autofill with the variables of the user that is currently logged in, it is an administrational function on the site where the admin can add new users to the system. I just want the text the user has entered into the form to stay when the error messages appear. Thanks
  16. Hi Guys, In many of my pages i am building, for example the ADD NEW EMPLOYEE page, i have a number of error messages that appear if the user leaves a text box blank. The problem I have is that If the user does leave a text box empty and the relevant text box is displayed then it completely clears what they have written so they must start again. How do I keep the text that has already been put into the form when these messages are displayed? Here is my code for the add user form.. <?php session_start(); if (isset($_SESSION['usernameAdmin']) == false){ header("Location: login.php"); exit(); } require "connect.php"; ?> <!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> <title>Add User</title> </head> <body> <?php include ("headerAdmin.php"); ?> <h1 align="center" class="style1"> </h1> <form action="addUserQuery.php" method="post"> <table width="100%" border="0"> <tr> <td> </td> <td> <h2 align="left">Create User</h2></td> <td> </td> </tr> <tr> <td width="28%"> </td> <td width="31%"> </td> <td width="41%"> </td> </tr> <tr> <td>Title:</td> <td><input name="title" type="text" /></td> <td><span class="style2"> <?php if(isset($_GET['message1'])) { echo $_GET['message1']; } ?> </span></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>First Name:</td> <td><input name="fName" type="text" /></td> <td><span class="style2"> <?php if(isset($_GET['message2'])) { echo $_GET['message2']; } ?> </span></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Surname:</td> <td><input name="sName" type="text" /></td> <td><span class="style2"> <?php if(isset($_GET['message3'])) { echo $_GET['message3']; } ?> </span></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Job Role:</td> <td><input name="jobRole" type="text" /></td> <td><span class="style2"> <?php if(isset($_GET['message4'])) { echo $_GET['message4']; } ?> </span></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Username:</td> <td><input name="username" type="text" /></td> <td><span class="style2"> <?php if(isset($_GET['message5'])) { echo $_GET['message5']; } ?> </span></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Password:</td> <td><input name="password" type="password" /></td> <td><span class="style2"> <?php if(isset($_GET['message6'])) { echo $_GET['message6']; } ?> </span></td> </tr> <tr> <td> </td> <td><?php if(isset($_GET['message7'])) { echo $_GET['message7']; } ?></td> <td><input name="Save" type="submit" value="Save" /></td> </tr> </table> </form> </body> </html> And here is the code that runs the query... <?php require "connect.php"; $title = $_POST['title']; $fName = $_POST['fName']; $sName = $_POST['sName']; $jobRole = $_POST['jobRole']; $username = $_POST['username']; $password = $_POST['password']; if($title == "") { $message1 = "Please enter the employees title"; header("Location: UserADD.php?message1=$message1"); exit(); } if($fName == "") { $message2 = "Please enter the employees first name"; header("Location: UserADD.php?message2=$message2"); exit(); } if($sName == "") { $message3 = "Please enter the employees surname"; header("Location: UserADD.php?message3=$message3"); exit(); } if($jobRole == "") { $message4 = "Please enter the employees job role"; header("Location: UserADD.php?message4=$message4"); exit(); } if($username == "") { $message5 = "Please enter your Username"; header("Location: UserADD.php?message5=$message5"); exit(); } if($password == "") { $message6 = "Please enter your Password"; header("Location: UserADD.php?message6=$message6"); exit(); } else if($title == !null || $fName == !null || $sName == !null || $jobRole == !null || $username == !null || $password == !null) { $query = "insert into employee values ('','".$title."','".$fName."','".$sName."','".$jobRole."','".$username."','".$password."','y')"; $result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); $message7 = "'".$fName."' '".$sName."' added successfully. "; header("Location: UserADD.php?message7=$message7"); exit(); } ?>
  17. Just changed that, thank you. Now what do i modify on this to auto fill the text box on the meeting room booking form? <input name="empID" value="<?=$_SESSION['empID']?>" />
  18. Ye, my session is declared in my logincheck.php page. This is it... <?php session_start(); require "connect.php"; $username = $_POST['username']; $password = $_POST['password']; $query = "select * from employee WHERE active ='y' AND username='".$username."' AND password='".$password."'"; $result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); $row=mysql_fetch_array($result); if($row!=null) { $_SESSION['username'] = $row['username']; header("Location: welcome.php"); exit(); } else if($username == "") { $message2 = "Please enter your Username"; header("Location: login.php?message2=$message2"); exit(); } else if($password == "") { $message3 = "Please enter your Password"; header("Location: login.php?message3=$message3"); exit(); } /*else if(active = "n") { $message4 = "Sorry, this users account has been de-activated. Please contact the system administrator." header("Location: login.php?message4=$message4"); exit(); }*/ else { $message = "Invalid user name or password, please try again"; header("Location: login.php?message=$message"); exit(); } ?>
  19. I've shown u my session code. thats all im using!?
  20. ...sorry i meant will that auto fill the text box in the form with the empID of the person currently logged in!??
  21. Will that auto fill the empID in the table with the empID of the person currently logged in?
  22. This is what follows that... It is a form asking the user to fill in the details of the meeting room they wish to book, i also want it to write into the table their empID which is not requested on the form but want it to be carried through to my query page (shown after). <body> <?php include ("header.php"); ?> <h2>Book a Meeting Room</h2> <h3> <form action="MeetingQuery.php" method="get"> <table width="99%" border="0"> <tr> <td width="29%">Select a building:</td> <td width="34%"><select name="building"> <option >[select a Building]</option> <option >North</option> <option >South</option> </select></td> <td width="22%"> </td> <td width="15%"> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Select a Meeting Room: </td> <td><select name="roomID"> <option >[select Meeting Room Number]</option> <option >020</option> <option >021</option> <option >105</option> <option >106</option> <option >113</option> <option >215</option> <option >216</option> </select></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Select a Date: </td> <td><p><script>DateInput('bkgDate', true, 'DD-MON-YYYY')</script></p></td> <td>Select a Time: </td> <td><select name="bkgTime"> <option >[select Meeting Time]</option> <option >0900-1000</option> <option >1000-1100</option> <option >1100-1200</option> <option >1200-1300</option> <option >1300-1400</option> <option >1400-1500</option> <option >1500-1600</option> <option >1600-1700</option> </select></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><?php if(isset($_GET['message1'])) { echo $_GET['message1']; } else if(isset($_GET['message2'])) { echo $_GET['message2']; } else if(isset($_GET['message3'])) { echo $_GET['message3']; } ?></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><input name="empID" value="<?=$_SESSION['empID']?>" /></td> <td> </td> <td><input name="Save" type="submit" value="Submit Meeting Room" /></td> <td> </td> </tr> </table> </form> </body> </html> QUERY PAGE <?php require "connect.php"; $roomID = $_GET['roomID']; $building = $_GET['building']; $bkgDate = $_GET['bkgDate']; $empID = $_GET['empID']; if($building == "[select a Building]") { $message1 = "Please select a building you wish to have the meeting in"; header("Location: MeetingMain.php?message1=$message1"); exit(); } if($roomID == "[select Meeting Room Number]") { $message2 = "Please select a Room Number"; header("Location: MeetingMain.php?message2=$message2"); exit(); } if($bkgTime == "[select Meeting Time]") { $message3 = "Please select a Meeting Time"; header("Location: MeetingMain.php?message3=$message3"); exit(); } else if($building == !null || $roomID == !null) { $query = "insert into booking ('','".$roomID."','".$empID."','".$bkgDate."','".$bkgTime."')"; $result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); //$message7 = "'".$fName."' '".$sName."' added successfully. "; //header("Location: UserADD.php?message7=$message7"); exit(); } ?>
×
×
  • 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.