473,609 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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 1177
missN32
2 New Member
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
2362
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, when the data already contains a " sign problem is like this: access database .... to update on the internet .... a *dataupdate.asp* page ..... On this page, the data gets displayed in a form where i
5
2427
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 somebody enters part_no, than using Javascript is it possible to connect to the part master and retrieve the division and desc information? I am not allowed to use the PHP because this will require the user to insert the part number on the first...
3
3119
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 in the form and hits the submit button, the data is entered and the form is reloaded with the new data displayed and another input form becomes the last line. Example --- Before entering new data
1
3014
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 in original website. How can I do that? Please help me out.
0
1320
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 predefined search. Say for a city. You have to use a form to get anything out of the system in return. You can link directly to a listing but not a search. Here is an example of one website that actually used a sliced up image map that does the search. ...
12
77976
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 give me some idea where I am going wrong ?? I just want to retrieve data from my emp_mstr table and display it using my JSP file... The table emp_mstr is as follows :- CREATE TABLE EMP_MSTR( EMP_NO VARCHAR(10) PRIMARY KEY, PASSWORD...
2
7149
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 cancel if wanted. I have the database. its has sample data. I can see the sample data from another machine. 'ssh'd' into the server and running mysql with appropriate commands. I have forms to retrieve the data and display the data on the screen...
5
3680
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 retrieve user input from a query form. In the Northwind DB, there is a query named "Invoices Filter". In the criteria for the OrderID field in the Invoices table, the following is entered: !! I understand that for this field, it's trying to...
2
13031
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- ZoneType 2- Consigneestbl with these fields: 1- ConID 2- ConName 3- Zone 4- ZoneType
0
8113
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8557
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8203
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8378
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5504
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4007
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2517
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.