salman_ahad@yahoo.com Posted November 1, 2009 Share Posted November 1, 2009 How to delete a range of table rows where id=1 to 100 $query = mysql_query("DELETE FROM all (id) VALUES (//range here ??)") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/179814-solved-delete-mysql-range/ Share on other sites More sharing options...
joel24 Posted November 1, 2009 Share Posted November 1, 2009 DELETE FROM *table* WHERE id BETWEEN 0 AND 101 Quote Link to comment https://forums.phpfreaks.com/topic/179814-solved-delete-mysql-range/#findComment-948631 Share on other sites More sharing options...
salman_ahad@yahoo.com Posted November 1, 2009 Author Share Posted November 1, 2009 Thanks Joel.. Also I need to pick some accounts between a datetime range of last 5 mins..this is what I got. $timenow = time(); $fiveminsb4 = $timenow - 300; $query_users = mysql_query("SELECT userid FROM *table* WHERE datetime BETWEEN '".$timenow."' AND '".$fiveminsb4."')"); //is there a better logic?? Quote Link to comment https://forums.phpfreaks.com/topic/179814-solved-delete-mysql-range/#findComment-948633 Share on other sites More sharing options...
joel24 Posted November 1, 2009 Share Posted November 1, 2009 you can do it all in mysql, without PHP. also you don't need between... now is the max time, so use greater than $query_users = mysql_query("SELECT userid FROM *table* WHERE datetime > NOW() - INTERVAL 5 MINUTE"); Quote Link to comment https://forums.phpfreaks.com/topic/179814-solved-delete-mysql-range/#findComment-948634 Share on other sites More sharing options...
salman_ahad@yahoo.com Posted November 1, 2009 Author Share Posted November 1, 2009 Thanks I also have error which picking user input variable... $Var=$_POST ['Variable'] $query_users = mysql_query("SELECT * FROM users WHERE userid='".$Var."')") or die(mysql_error()); //Why is it not working Quote Link to comment https://forums.phpfreaks.com/topic/179814-solved-delete-mysql-range/#findComment-948798 Share on other sites More sharing options...
Alex Posted November 1, 2009 Share Posted November 1, 2009 You have an extra ) in the query. Quote Link to comment https://forums.phpfreaks.com/topic/179814-solved-delete-mysql-range/#findComment-948800 Share on other sites More sharing options...
salman_ahad@yahoo.com Posted November 1, 2009 Author Share Posted November 1, 2009 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/179814-solved-delete-mysql-range/#findComment-948814 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.