Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6873487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:04:30+00:00 2026-05-27T04:04:30+00:00

I have 3 tables: table events . In this I have fields such as

  • 0

I have 3 tables:

  1. table events. In this I have fields such as
    event_id, user_id, title, email, location, address, latitude, longitude, description, isapproved

  2. table event_time. In this I have fields
    show_id, event_id, start_date, start_time, end_date, duration, date, end_time

  3. table category:
    id, cat_id, event_id

I am inserting data into 3 tables so that if an event of event_id 5 is entered into the event table then the corresponding data will be filled in event_title and category.
While filling event_time table if the events start_time is 2011-12-05 and end_date is 2011-12-07 then event_time table will filled with 3 rows like with same event id and different date:

show_id  event_id   start_date  start_time  end_date    duration  date          end_time
11       5          2011-12-05  12:00:00    2011-12-07  03:00:00  2011-12-07    15:00:00
10       5          2011-12-05  12:00:00    2011-12-07  03:00:00  2011-12-06    15:00:00
9        5          2011-12-05  12:00:00    2011-12-07  03:00:00  2011-12-05    15:00:00

The category table will be entered based on
number of categories selected in category drop down list.

id  cat_id  event_id
25  3   5
24  5   5

Now I want to delete the event from the database based on user choice. If he wants to delete the event of particular date then only in event_time it should get deleted in events, category it should be there.
But if user wants to delete event not based on any date the data from all the table should be removed.

<?php
include_once("webconfig.php");
include_once("webdatabase.php");
$show_id = isset($_REQUEST['show_id'])?trim($_REQUEST['show_id']):"";
$event_id = isset($_REQUEST['event_id'])?trim($_REQUEST['event_id']):"";

if(isset($show_id))
{
$s="select * from event_time where event_id='$event_id'";
$num_rows = mysql_num_rows($s);
die($num_rows);
$exe=$db->query($s);
if($db->row_count()==1)
{
$sql ="Delete events,event_time,category from events join event_time join category         on(events.event_id=event_time.event_id and event_time.event_id=category.event_id) where event_time.show_id='$show_id'";
$exe=$db->query($sql);
$successMsg = "deleted Successfully! . ";
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= '<root>';
$xml .= '<delete>';
$xml .= '<status>True</status>';
$xml .= "<message>$successMsg</message>";
$xml .= '</delete>';
$xml .= '</root>';
echo $xml;
}
else
{
$sql1 ="Delete event_time from event_time where event_time.show_id='$show_id'";
e=$db->query($sql1);
$successMsg = "deleted Successfully! . ";
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= '<root>';
$xml .= '<delete>';
$xml .= '<status>True</status>';
$xml .= "<message>$successMsg</message>";
$xml .= '</delete>';
$xml .= '</root>';
echo $xml;
}
}
else
{
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= '<root>';
$xml .= '<delete>';
$xml .= '<status>false</status>';
$xml .= "<message>no data found</message>";
$xml .= '</delete>';
$xml .= '</root>';
echo $xml;
}
?>

this is what the code i have written.
Anyone know how to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:04:30+00:00Added an answer on May 27, 2026 at 4:04 am

    You will probably have to do all this in your code. You can use triggers if your database platform supports it, and also you should look into constraints and the cascade options.

    An “on delete cascade” constraint for example would automatically handle the case where you delete an event, as it would delete the related records in event_time and category for you.

    The simplest solution to start with is to use code though. So in your app, determine what needs cleaning out, and issue the deletes yourself.

    To delete all time and event info for one event:

    DELETE FROM event_time WHERE event_id = 5;
    DELETE FROM event WHERE event_id = 5;
    DELETE FROM category WHERE event_id = 5;
    

    Or obviously to delete just the times:

    DELETE FROM event_time WHERE show_id = 23;
    

    You’ll need to handle the case where there is only one time, should the event be kept in that case? That’s up to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, events and photos, which relate together via the 'Event_ID' column.
I have 3 tables event, location, event_location. Event can have multiple locations. Location table
I have a table called events with 5 fields. Among those fields I have
I have two tables called 'events' and 'topics' each table can have many comments.
I have a database table that represents Events. The table has 2 main fields
I have a table of events with a recorded start and end time as
I have a table of events, I need to find all tail events of
I have an Events table whose goal is to store actions done by web
Suppose you have the tables Presentations and Events . When a presentation is saved
I have a table of data which represents a series of events that persons

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.