big-dog1965 Posted May 25, 2009 Share Posted May 25, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/159527-deleting-data-from-2-fields-but-not-the-whole-row/ Share on other sites More sharing options...
Ken2k7 Posted May 25, 2009 Share Posted May 25, 2009 Well your DB design is off. You want to use UPDATE and just set it to some reset value. Quote Link to comment https://forums.phpfreaks.com/topic/159527-deleting-data-from-2-fields-but-not-the-whole-row/#findComment-841513 Share on other sites More sharing options...
big-dog1965 Posted May 25, 2009 Author Share Posted May 25, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/159527-deleting-data-from-2-fields-but-not-the-whole-row/#findComment-841515 Share on other sites More sharing options...
Ken2k7 Posted May 25, 2009 Share Posted May 25, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/159527-deleting-data-from-2-fields-but-not-the-whole-row/#findComment-841520 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.