dachshund Posted August 2, 2009 Share Posted August 2, 2009 ok, so here i want it to choose 4 random 'feature' articles, apart from the most recent one, ie. the highest 'id' which also has the section LIKE '%feature%' anyway to do this? here's what I've got $sql = "SELECT * FROM content WHERE `section` LIKE '%feature%' ORDER BY RAND() LIMIT 1,4"; Link to comment https://forums.phpfreaks.com/topic/168501-help/ Share on other sites More sharing options...
Bricktop Posted August 2, 2009 Share Posted August 2, 2009 Hi asurfaceinbetween, You need to order by id and then radomise from that, something like the below should work: $sql = "SELECT * FROM (SELECT * FROM content WHERE `section` LIKE '%feature%' ORDER BY id desc limit 1,4) as id ORDER BY rand() limit 0,4"; Link to comment https://forums.phpfreaks.com/topic/168501-help/#findComment-888906 Share on other sites More sharing options...
dachshund Posted August 2, 2009 Author Share Posted August 2, 2009 yeah i see what you mean. that one doesn't quite work though. just comes up blank. Link to comment https://forums.phpfreaks.com/topic/168501-help/#findComment-888999 Share on other sites More sharing options...
dachshund Posted August 2, 2009 Author Share Posted August 2, 2009 anyone know what's wrong? Link to comment https://forums.phpfreaks.com/topic/168501-help/#findComment-889014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.