473,511 Members | 16,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

View only results in table with certain information (only when conformation = No)

6 New Member
I have two table here uncorfirmed booking and confirmed bookings

I only want data to be listed in the unconfirmed booking table when conformation = no

and in only want data to be lised in confirmed booking table when conformation = yes

Any ideas of the code i would have to add and where to add it please

thanks

Expand|Select|Wrap|Line Numbers
  1. <h1>Booking Table (Unconfirmed Booking)</h1>
  2.  
  3. <?php
  4.  
  5. include("config.php");
  6.  
  7. $con = mysql_connect($mysql_host, $mysql_user, $mysql_password); 
  8.  
  9. mysql_select_db($mysql_database, $con); 
  10.  
  11. $result = mysql_query("SELECT * FROM names");
  12.  
  13. echo "<table border='1'>
  14. <tr>
  15. <th>Booking ID</th>
  16. <th>Firstname</th>
  17. <th>Lastname</th>
  18. <th>Adress</th>
  19. <th>City / Town</th>
  20. <th>Postcode</th>
  21. <th>Phone Number</th>
  22. <th>E-Mail</th>
  23. <th>Cottage</th>
  24. <th>Start Date</th>
  25. <th>End Date</th>
  26. <th>Conformation</th>
  27. <th>Confirm Booking</th>
  28. <th>Delete Booking</th>
  29. </tr>";
  30.  
  31. while($row = mysql_fetch_array($result))
  32.   {
  33.   echo "<tr>";
  34.   echo "<td>" . $row['bookid'] . "</td>";
  35.   echo "<td>" . $row['firstname'] . "</td>";
  36.   echo "<td>" . $row['lastname'] . "</td>";
  37.   echo "<td>" . $row['address'] . "</td>";
  38.   echo "<td>" . $row['citytown'] . "</td>";
  39.   echo "<td>" . $row['postcode'] . "</td>";
  40.   echo "<td>" . $row['phonenumber'] . "</td>";
  41.   echo "<td>" . $row['emailaddress'] . "</td>";
  42.   echo "<td>" . $row['cottage'] . "</td>";
  43.   echo "<td>" . $row['startdate'] . "</td>";
  44.   echo "<td>" . $row['enddate'] . "</td>";
  45.   echo "<td>" . $row['conformation'] . "</td>";
  46.   echo "<td><a href=\"conbook.php?bookid=". $row['bookid']."\" onclick=\"return confirm('Are you sure you want to confirm booking?');\"> Confirm </a></td>";
  47.   echo "<td><a href=\"delbook.php?bookid=". $row['bookid']."\" onclick=\"return confirm('Are you sure you want to delete record?');\"> Delete </a></td>";
  48.   echo "</tr>";
  49.   }
  50. echo "</table>";
  51.  
  52. mysql_close($con); 
  53.  
  54. ?>
  55.  
  56. <h1>Booking Table (Confirmed Booking)</h1>
  57.  
  58. <p>
  59.   <?php
  60.  
  61. include("config.php");
  62.  
  63. $con = mysql_connect($mysql_host, $mysql_user, $mysql_password); 
  64.  
  65. mysql_select_db($mysql_database, $con); 
  66.  
  67. $result = mysql_query("SELECT * FROM names");
  68.  
  69. echo "<table border='1'>
  70. <tr>
  71. <th>Booking ID</th>
  72. <th>Firstname</th>
  73. <th>Lastname</th>
  74. <th>Adress</th>
  75. <th>City / Town</th>
  76. <th>Postcode</th>
  77. <th>Phone Number</th>
  78. <th>E-Mail</th>
  79. <th>Cottage</th>
  80. <th>Start Date</th>
  81. <th>End Date</th>
  82. <th>Conformation</th>
  83. <th>Unconfirm Booking</th>
  84. <th>Delete Booking</th>
  85. </tr>";
  86.  
  87. while($row = mysql_fetch_array($result))
  88.   {
  89.   echo "<tr>";
  90.   echo "<td>" . $row['bookid'] . "</td>";
  91.   echo "<td>" . $row['firstname'] . "</td>";
  92.   echo "<td>" . $row['lastname'] . "</td>";
  93.   echo "<td>" . $row['address'] . "</td>";
  94.   echo "<td>" . $row['citytown'] . "</td>";
  95.   echo "<td>" . $row['postcode'] . "</td>";
  96.   echo "<td>" . $row['phonenumber'] . "</td>";
  97.   echo "<td>" . $row['emailaddress'] . "</td>";
  98.   echo "<td>" . $row['cottage'] . "</td>";
  99.   echo "<td>" . $row['startdate'] . "</td>";
  100.   echo "<td>" . $row['enddate'] . "</td>";
  101.   echo "<td>" . $row['conformation'] . "</td>";
  102.   echo "<td><a href=\"unconbook.php?bookid=". $row['bookid']."\" onclick=\"return confirm('Are you sure you want to unconfirm booking?');\"> Unconfirm </a></td>";
  103.   echo "<td><a href=\"delbook.php?bookid=". $row['bookid']."\" onclick=\"return confirm('Are you sure you want to delete record?');\"> Delete </a></td>";
  104.   echo "</tr>";
  105.   }
  106. echo "</table>";
  107.  
  108. mysql_close($con);
  109.  
  110. ?>
  111. <p>
  112.   <INPUT type="button" value="Log Out" onClick="location.href='adminlog.php'">
  113.   <html>
Jun 16 '10 #1
1 1402
JKing
1,206 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. //Change line 11 to this
  2. $result = mysql_query("SELECT * FROM names WHERE conformation = 'yes'");
  3.  
  4. //Change line 67 to
  5. $result = mysql_query("SELECT * FROM names WHERE conformation = 'no'");
  6.  
What you are doing is adding a where clause to pull the appropriate data based off your conformation field. Now I am assuming here that the field conformation is a string equal to yes or no and not a boolean.
Jun 17 '10 #2

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

Similar topics

2
2049
by: ywchan | last post by:
I have implemnt a onBlur event of a text input. In the event, a window with all records which related to the text input will be shown. However, I don't want to pop up the window in case there is...
1
1965
by: Nathan Baulch | last post by:
I have a page with EnableViewState="false". That page contains a DropDownList with dynamic items and a submit Button. I need to get the SelectedIndex of the DropDownList on postback however all...
4
2969
by: Scot L. Harris | last post by:
Currently using Postgresql 7.2.4-5.80 with php 4.2.2.-8.0.8 on a redhat 8.0 system. I am writing some php scripts where I want to generate a list of the column names in a particular table that...
2
1406
by: AA Arens | last post by:
When I finished whitch the Design View and want to go back to normal view, the form does not appear. Instead of that the table appears. I only get the form when I cal it on the Switchboard. How...
2
4756
by: l!m!t | last post by:
Hello, I hope somebody can help me I have been at this for hours. I am new to JavaScript. I need a script to show a layer of hidden content only when on a certain URL. I have searched and...
4
1973
by: jonceramic | last post by:
Hi all, I have a situation I can't find any old messages or web-help on. I have a split database with a bizarre quirk. When I open up the front-end file, the main form opens up fairly quickly...
1
1797
by: matturn | last post by:
Is it possible to select elements only when they have certain children? I wish to reduce the margin on "a:hover"s, but only when they have a UL child. Is this possible, or must I give every link...
2
1945
by: mariaz | last post by:
Hello, I am creating a project where I parse an xml page (feed from a website) in a javabean file and I insert the parsed data in a mysql database. I want this data that gets inserted into the...
13
23443
by: amit2781 | last post by:
How can we get the table schema information in MYSQL 5.1.34? Like we use in ORACLE to get it as: OCIDescribeAny() // //get the describe handle for the table to be described. OCIAttrGet() ...
0
7242
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
7138
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
7353
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,...
0
7418
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
5662
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
3222
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...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.