how to do both inserting and deleting data from mysql using one php file

Questionshow to do both inserting and deleting data from mysql using one php file
sethbeckerman5 Staff asked 4 years ago

I'm working with Android Studio,
and using php and mySQL to use my data.
my table's name is 'laundry'
and it has columns named 'lmachine', 'lroom', and 'ltime'.
I used below code to insert new data to my db and it worked well.

in this php file, I want to add a query to delete rows which 'ltime' is older than now.
that query is 'delete from laundry where ltime < now()'. I checked whether this query works (in phpMyAdmin console) and it worked.
I want to put that query in upper php file.
so tried this code

and it doesn't work. I wonder if my approach was wrong or it's matter of syntax.

' doesn't work ' means… when I run a project using this php file in Android Studio, there's no error log, inserting data works as before but deleting data doesn't work. And the php file itself also works without any error message.


View on Stack Overflow