Jump to content

deleting data from 2 fields but not the whole row


big-dog1965

Recommended Posts

Is there a way to delete data from 2 fields in a table record?

I have a table with date1, time1, date2, time2, date3, time3, date4, time4

I would like to delete the data from date1, and time1

Something like this

DELETE FROM Venues WHERE DATE_SUB(CURDATE(),INTERVAL 1 DAY) >= `Date1`';

but not the whole row also instead of just the date1 field delete the time1 field data as well then when the next date is 1 day old it deletes date2 and time2. and so on till date4 and time4 is 1 day old and it deletes the record.

 

I’m using a webpage to display records and want it to be updated or only show date and time if the date and corresponding time field is not in the past

 

the insert is

$query = "INSERT into `".$db_table."` (venue,address,date_1,time_1,date_2,time_2,date_3,time_3,date_4,time_4,host,host_email,venue_website,venue_phone,logo_image) VALUES ('" . $_POST['venue'] . "','" . $_POST['address'] . "','" . $_POST['date_1'] . "','" . $_POST['time_1'] . "','" . $_POST['date_2'] . "','" . $_POST['time_2'] . "','" . $_POST['date_3'] . "','" . $_POST['time_3'] . "','" . $_POST['date_4'] . "','" . $_POST['time_4'] . "','" . $_POST['host'] . "','" . $_POST['host_email'] . "','" . $_POST['venue_website'] . "','" . $_POST['venue_phone'] . "','" . $_FILES['logo_image']['name'] . "')";

What do I need to do to DB design to make it work better Im using a form then the form uses a proccess.php to insert into mysql

 

I don't know the use of the date1, time1, etc. fields as they are ambiguous. You could have a new table for them with a few columns (id, date, time) and that should allow you to delete. But, to just solve your query, read -

 

You want to use UPDATE and just set it to some reset value.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.