sstangle73 Posted August 23, 2007 Share Posted August 23, 2007 $query="SELECT * FROM users where id = 0-20 $query="SELECT * FROM users where id = 21-40 i want it to do that but im not sure of the correct code can someone tell me please Link to comment https://forums.phpfreaks.com/topic/66294-solved-mysql/ Share on other sites More sharing options...
phpQuestioner Posted August 23, 2007 Share Posted August 23, 2007 maybe something like this: <?php if ($id <= 20) { $id="something"; } else { $id="something2"; } $query="SELECT * FROM users where id='$id'" ?> Link to comment https://forums.phpfreaks.com/topic/66294-solved-mysql/#findComment-331648 Share on other sites More sharing options...
keeB Posted August 23, 2007 Share Posted August 23, 2007 <?php $query="SELECT * FROM users where id >= 0 and id <= 20" $q2 = "$query="SELECT * FROM users where id >= 21 and <= 40" ?> Link to comment https://forums.phpfreaks.com/topic/66294-solved-mysql/#findComment-331653 Share on other sites More sharing options...
Barand Posted August 23, 2007 Share Posted August 23, 2007 or $query="SELECT * FROM users where id BETWEEN 21 AND 40 Link to comment https://forums.phpfreaks.com/topic/66294-solved-mysql/#findComment-331659 Share on other sites More sharing options...
beboo002 Posted August 23, 2007 Share Posted August 23, 2007 select * from abhi where name =>5 and name <=10 ; use this code insted of $query="SELECT * FROM users where id = 0-20 Link to comment https://forums.phpfreaks.com/topic/66294-solved-mysql/#findComment-331666 Share on other sites More sharing options...
keeB Posted August 24, 2007 Share Posted August 24, 2007 or $query="SELECT * FROM users where id BETWEEN 21 AND 40 Learn something new every day, didn't know about the BETWEEN keyword. Thanks B! Link to comment https://forums.phpfreaks.com/topic/66294-solved-mysql/#findComment-332679 Share on other sites More sharing options...
sstangle73 Posted August 24, 2007 Author Share Posted August 24, 2007 yeah thats a nice feature to know thanks b thats the one i tried and it worked Link to comment https://forums.phpfreaks.com/topic/66294-solved-mysql/#findComment-333009 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.