I want to delete records from mysql using php
the field name: Week
Week records values as below:
200801
200802
200803
200804
200805
etc
I created TextField named “tYear”, user will insert first 4 numbers from the left and sql statement should remove all the records starting with them, example … if the user insert 2008 all the above records as they starting with 2008 should be removed.
I am using sql statement as below but it’s not working
$sql= "DELETE from sites WHERE Week like '". $_POST['tYear']."'";
$results = mysql_query($sql);
your query is :
$sql= “DELETE from sites WHERE Week like ‘”. $_POST[‘tYear’].”‘”;
and with
likein mysql you have to uselike '%%' or like '%'for so use :