473,394 Members | 1,759 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,394 software developers and data experts.

How to update data in the database when deleting

115 100+
Hi i'm working on a tourism site . and i am working in the admin page . exactly in the delete_reservation.php .
first i have this page view_reservation.php :
This page allow the admin to see all the reservation made by the customers , he can edit or delete any reservation made.
I want when he delete the reservation made by the customer to modify the table tours, depending on what he had delete.
her is the tables tours and orders (represents the reservations made by the customers): tours(tour_id,title,description,date,price,image,m ax_place)
orders(order_id,user_id,tour_id,date_order,cust_nu m)
the tours.max_place represents the maximum number of customers that can reserve in a trip, and the orders.cust_num represent the number of persons that have reserved in a tour.
i want to when the admin click on delete , to delete a reservation made by the customer . to update tours.max_place ...
therefore i wrote this function :
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. class Reservation{
  3.     require("../../include/database.php");
  4. function delete_res($orderid){
  5.     $query="SELECT t.tour_id,t.max_place,o.cust_num,o.order_id
  6.             FROM tours t, orders o
  7.             WHERE t.tour_id=o.tour_id
  8.             AND o.order_id=" .$orderid;
  9.  
  10.     $res=mysql_query($query);
  11.     echo $res;
  12.     while($array = mysql_fetch_array($res)){
  13.     $toPut=($array[cust_num] + $array['max_place']);
  14.     //echo $toPut;
  15.     $query="UPDATE tours SET max_place= '$toPut' WHERE  t.tour_id=" .$array[tour_id];
  16.     mysql_query($query) or die ("not done");
  17.     mysql_query("DELETE FROM `orders` WHERE order_id = $orderid");}
  18. }
  19. }
  20. ?>
and this is the delete_reservation.php
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. session_start();
  4. require_once("../../include/database.php");
  5. require_once("../../functions.php");
  6. $id = $_GET[id];
  7. Reservation::delete_res($id);   
  8.  
  9.   //get download files of the specific category
  10.  
  11. ?>
  12. <script language="javascript">
  13. alert('Data Deleted Successfully');
  14. location = 'view_res.php';
  15. </script>
  16.  
and this is the page view_reservation.php
Expand|Select|Wrap|Line Numbers
  1. <html>...<body>
  2.  
  3.         <?php
  4.         require("../../include/database.php");
  5.   //get download files of the specific category
  6.   $Get_Query = "SELECT t.title,t.description,t.price,t.date,t.image,t.tour_id,o.order_id,o.date_order,o.cust_num,u.user_id,u.full_name
  7.                 FROM `tours` t,`orders` o, `users` u
  8.                 WHERE o.tour_id=t.tour_id
  9.                 and o.user_id=u.user_id
  10.                 ORDER BY order_id";
  11.  
  12.   $result    =  mysql_query($Get_Query);
  13.  
  14.   while($row = mysql_fetch_array($result))
  15.   {
  16.  
  17. ?>
  18.         <tr>
  19.           <td align="center" valign="top"><div align="center"><?php echo $row[title] ?></div></td>
  20.           <td align="center" valign="top"><div align="center"><?php echo $row[full_name] ?> </div></td>
  21.           <td align="center" valign="top"><div align="center"><?php echo $row[price] ?></a></div></td>
  22.           <td align="center" valign="top"><div align="center"><?php echo $row[date] ?></a></div></td>
  23.           <td align="center" valign="top"><div align="center"><?php echo $row[cust_num] ?></a></div></td>         
  24.  
  25.          <td align="center" valign="top"><div align="center"><a href="edit_res.php?id=<?php echo $row[order_id] ?>">Edit</a></div></td>
  26.  
  27.          <td align="center" valign="top"><div align="center"><a href="delete_res.php?id=<?php echo $row[order_id] ?>" onclick="return confirm('Are you sure you want to delete?')">Delete</a></div></td>
  28.         </tr>
  29.         <?php }//while ?>
  30.       </table>
  31.     </div></td>
  32.   </tr>
  33.   </table>
  34. </form>
  35. <p>&nbsp;</p>
  36. </body>
  37. </html>
  38.  
but it's not working it keep giving me this error
Fatal error: Class 'Reservation' not found in C:\wamp\www\tours mazbouta\Admin\reservation\delete_res.php on line 6
could any one know why ? Help please .... Thanks for advance
Sep 23 '10 #1
4 1860
JKing
1,206 Expert 1GB
Is your page named delete_reservation.php or delete_res.php?

Also have you added your class Reservation to your functions.php?
Sep 23 '10 #2
hannoudw
115 100+
the name of the page delete_res.php (but i said delete_reservation.php for more explanation)
this is the code of delete_res.php
and yes i added my class to the function by including the function.php on line 3
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. require_once("../../functions.php");
  4. $id = $_GET[id];
  5. Reservation::delete_res($id);   
  6.  
  7.   //get download files of the specific category
  8.  
  9. ?>
  10. <script language="javascript">
  11. alert('Data Deleted Successfully');
  12. location = 'view_res.php';
  13. </script>
Sep 25 '10 #3
JKing
1,206 Expert 1GB
Yes you have included the file functions.php on line 3 but is the code for your class Reservations in your functions.php file?
Sep 27 '10 #4
hannoudw
115 100+
Yes the code of the class Reservation is in the functions.php file !
Sep 27 '10 #5

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

Similar topics

4
by: Mark | last post by:
Not sure this is the right place for this questions, but here goes: I get an error message when deleting an table from a Access database. The code is as follows and the error message is after...
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
4
by: TT (Tom Tempelaere) | last post by:
Hi, Suppose there is a DataGrid on a form bound to a DataTable. When a user is editing a cell without leaving the cell, and then closes the form, the value is not updated to the underlying data...
3
by: Alpha | last post by:
Hi, I have a datagrid and its source is a dataset. When I change information on the grid does that automatically gets change in the dataset? If not then how do I do that? I use the following...
2
by: Jake_adl | last post by:
Is there any way to create a Microsoft.Practices.EnterpriseLibrary.Data.Database object without reading from a configuration file? I am writing a utility that manages databases in SQL Server....
3
by: Simon | last post by:
Hi everyone, I have a small problem regarding a wizard that I'm making on my website. The wizard is obviously a series of pages that take values from the user. My question is: - Should I...
6
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application...
2
by: Ville Mattila | last post by:
Hi there, I will post my question to this group too bacause the .data group seems to be rather quiet. I've been playing with VB.NET and ADO for a week now and find the different data handling...
5
by: John Veldthuis | last post by:
My code works perfectly 100% when adding items to my ArrayList and updating the listbox. Works perfectly when deleting an item in the ArrayList when it is not the last entry but if it is the last...
1
by: =?Utf-8?B?QW5kcmU=?= | last post by:
I used the wizard in VS2005 to create my connection, dataset, and tableadaptor I have a typed dataset named dsUserInfo I have a tableadaptor named taFillUserInfo I would like to on the vb side...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
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...

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.