473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

retrieve data from database based on my form input, want to display all the submitted

Expand|Select|Wrap|Line Numbers
  1. <?php require_once('Connections/try1.php'); ?> <?php
  2. if (!function_exists("GetSQLValueString")) {
  3. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  4. {
  5.   if (PHP_VERSION < 6) {
  6.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  7.   }
  8.  
  9.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  10.  
  11.   switch ($theType) {
  12.     case "text":
  13.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  14.       break;    
  15.     case "long":
  16.     case "int":
  17.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  18.       break;
  19.     case "double":
  20.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  21.       break;
  22.     case "date":
  23.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  24.       break;
  25.     case "defined":
  26.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  27.       break;
  28.   }
  29.   return $theValue;
  30. }
  31. }
  32.  
  33. $editFormAction = $_SERVER['PHP_SELF'];
  34. if (isset($_SERVER['QUERY_STRING'])) {
  35.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  36. }
  37.  
  38. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
  39.   $insertSQL = sprintf("INSERT INTO borrowitem (booking_ID, item, borrower_name, borrower_ID, deptCollege, borrower_phone, borrower_email, borrower_dateuse, borrower_timeuse, purposeuse, locationuse) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
  40.                        GetSQLValueString($_POST['book'], "int"),
  41.                        GetSQLValueString($_POST['Item'], "text"),
  42.                        GetSQLValueString($_POST['name'], "text"),
  43.                        GetSQLValueString($_POST['id'], "text"),
  44.                        GetSQLValueString($_POST['co'], "text"),
  45.                        GetSQLValueString($_POST['phonenum'], "text"),
  46.                        GetSQLValueString($_POST['useremail'], "text"),
  47.                        GetSQLValueString($_POST['startdate1'], "date"),
  48.                        GetSQLValueString($_POST['stime'], "date"),
  49.                        GetSQLValueString($_POST['purposeuse'], "text"),
  50.                        GetSQLValueString($_POST['locationuse'], "text"));
  51.  
  52.   mysql_select_db($database_try1, $try1);
  53.   $Result1 = mysql_query($insertSQL, $try1) or die(mysql_error());
  54.  
  55.   $insertGoTo = "display.php";
  56.   if (isset($_SERVER['QUERY_STRING'])) {
  57.     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  58.     $insertGoTo .= $_SERVER['QUERY_STRING'];
  59.   }
  60.   header(sprintf("Location: %s", $insertGoTo));
  61. }
  62.  
  63. mysql_select_db($database_try1, $try1);
  64. $query_display = "SELECT * FROM borrowitem ORDER BY booking_ID ASC";
  65. $display = mysql_query($query_display, $try1) or die(mysql_error());
  66. $row_display = mysql_fetch_assoc($display);
  67. $totalRows_display = mysql_num_rows($display);
  68.  
  69.  
  70. ?> <?php include("try1.php") ?> <html> <head> <title>menu</title> </head> <body bgcolor="#F4FA58"> <form action="<?php echo $editFormAction; ?>" name="form" method="POST"> <table border="1" width="489" align="center"> <tr> <td width="182"><table border="1" width="489" align="center"> <tr> <td width="203" align="left"><font color="#0000FF">Booking ID: </font></td> <td width="270"><input type="text" name="book" size="20"></td> <tr> <td width="203" align="left"><font color="#0000FF">Staff ID / Student ID: </font></td> <td width="270"><input type="text" name="id"; size="20"></td> </tr> <tr> <td width="203" align="left"><font color="#0000FF">Name</font></td> <td width="270"><input type="text" name="name" size="40"></td> </tr> <tr> <td width="203" align="left"><font color="#0000FF">Course/College :</font></td> <td width="270"><input type="text" name="co" size="40"></td> </tr> <tr> <td><font color="#0000FF">Choose your Item : </font></td> <td><select name="Item"> <option value="LCDprojector">LCD_Projector</option> <option value="Screen">Screen</option> <option value="Screen&LCDProjector">Screen &LCD Projector</option> </select></td> </tr> <tr> <td width="203" align="left"><font color="#0000FF">Date Use : </font></td> <td width="270"><input name="startdate1" type="date"  value="<?php if(isset($_POST['startdate1'])){ echo $_POST['startdate1']; }?>" /></td> </tr> <tr> <td width="203" align="left"><font color="#0000FF">Time Use : </font></td> <td width="270"><input type="time" name="stime"; size="10"> </td> </tr> <tr> <td width="203" align="left"><font color="#0000FF">Purpose : </font></td> <td width="270"><input type="text" name="purposeuse"; size="45"></td> </tr> <tr> <td width="203" align="left"><font color="#0000FF">Location : </font></td> <td width="270"><input type="text" name="locationuse"; size="45"></td> </tr> <tr> <td width="203" align="left"><font color="#0000FF">Phone Number : </font></td> <td width="270"><input type="text" name="phonenum"; size="45"></td> </tr> <tr> <td width="203" align="left"><font color="#0000FF">Email : </font></td> <td width="270"><input type="text" name="useremail"; size="45"></td> </tr> </table></td> </tr> </table> <p align="center"><input type="submit" value="Submit"> <input type="reset" value="Reset"> <input type="hidden" name="MM_insert" value="form"> </form> </body> </html> <?php
  71. mysql_free_result($display);
  72. ?>
Sep 17 '15 #1
1 1170
i want to display the submitted form. i want to retrieve data from the item table in my database. when there's another user, i want it to compare whether there's still item in that table or not.. once booked, the column status in the table item will change to unavailable. only the admin can update this. if theres user who want to book, and if theres no item left, it will print "Sorry there's no more left" or something like that. can someone help me?
Sep 17 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: cooldv | last post by:
i know how to replace the sign " when SUBMITTING a form in asp by this code: message = Replace(usermessage, "'", "''"). My problem is DISPLAYING data in an asp FORM, from an an access database,...
5
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using Javascript but by accessing the Database. Say...
3
by: Bob Sanderson | last post by:
I am trying to create a form for a MySQL database similar to a spreadsheet. The idea is to display a list of records, with the last line of the list being an input form. When the user enters data...
1
by: deepaks85 | last post by:
Dear Sir, Is there any way to Get / Retrieve data from any website? I want the contents from a website into my website so that the contents can automatically update if the contents get changed...
0
by: im20 | last post by:
I am helping a polish up a client's PPC campaign and when of the problems I have run into is that the real estate backend system he is using, does not allow the ability to link directly to a...
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
2
by: metparker | last post by:
Hi everyone. I am trying to create a web form that will let search for records. the form will display the results on a screen that will enable the viewer to edit the record and then re-save it or...
5
by: erog | last post by:
Hello I've tried using the MS Access Northwind sample DB and I've downloaded a few other sample Microsoft Access DBs from their website. I keep on running into the same problem for trying to...
2
by: irslan rafique | last post by:
Hi, I am creating a database using Access 2010 Web Database. I have two tables: 1-Maintbl with these fields: 1- Date 2- RTNo 3-DriverName 4- ConID 5-ConName 6- Zone 7-...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.