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
- <?php
- class Reservation{
- require("../../include/database.php");
- function delete_res($orderid){
- $query="SELECT t.tour_id,t.max_place,o.cust_num,o.order_id
- FROM tours t, orders o
- WHERE t.tour_id=o.tour_id
- AND o.order_id=" .$orderid;
- $res=mysql_query($query);
- echo $res;
- while($array = mysql_fetch_array($res)){
- $toPut=($array[cust_num] + $array['max_place']);
- //echo $toPut;
- $query="UPDATE tours SET max_place= '$toPut' WHERE t.tour_id=" .$array[tour_id];
- mysql_query($query) or die ("not done");
- mysql_query("DELETE FROM `orders` WHERE order_id = $orderid");}
- }
- }
- ?>
Expand|Select|Wrap|Line Numbers
- <?php
- session_start();
- require_once("../../include/database.php");
- require_once("../../functions.php");
- $id = $_GET[id];
- Reservation::delete_res($id);
- //get download files of the specific category
- ?>
- <script language="javascript">
- alert('Data Deleted Successfully');
- location = 'view_res.php';
- </script>
Expand|Select|Wrap|Line Numbers
- <html>...<body>
- <?php
- require("../../include/database.php");
- //get download files of the specific category
- $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
- FROM `tours` t,`orders` o, `users` u
- WHERE o.tour_id=t.tour_id
- and o.user_id=u.user_id
- ORDER BY order_id";
- $result = mysql_query($Get_Query);
- while($row = mysql_fetch_array($result))
- {
- ?>
- <tr>
- <td align="center" valign="top"><div align="center"><?php echo $row[title] ?></div></td>
- <td align="center" valign="top"><div align="center"><?php echo $row[full_name] ?> </div></td>
- <td align="center" valign="top"><div align="center"><?php echo $row[price] ?></a></div></td>
- <td align="center" valign="top"><div align="center"><?php echo $row[date] ?></a></div></td>
- <td align="center" valign="top"><div align="center"><?php echo $row[cust_num] ?></a></div></td>
- <td align="center" valign="top"><div align="center"><a href="edit_res.php?id=<?php echo $row[order_id] ?>">Edit</a></div></td>
- <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>
- </tr>
- <?php }//while ?>
- </table>
- </div></td>
- </tr>
- </table>
- </form>
- <p> </p>
- </body>
- </html>
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