zaidy26 Posted November 5, 2010 Share Posted November 5, 2010 Hi guys this is my first post, new to web development so please forgive me for my ignorance. Ok , i,m busy with a site , where im running ads , i display ads on a page and keep a counter in a database of the number of page refreshes i have and the number of adds i have . so for instance if i am on 600 page refreshes and i have 20 adds , i divide 600 by 20 and use the remainder number which will always be between 0 and 19. Ok now i need to query my ads database and display ads where the add id is greater the the remainder i get from the above query , so if my remainder was 3 , i want to show add 4 , 5 , 6 , 7 , my problem is , say the remainder was 19 , it needs to show add 20 , 1 , 2 3 . so it must start back at one , so i cant use the > operator , because it wont bring 1 2 3, Currently im saying SELECT * FROM kokan_ads WHERE kokan_ads.id > $remainderdnumber but this will only work fine till you reach a point where it must restart. Any help please Link to comment https://forums.phpfreaks.com/topic/217828-mysql-help-with-query/ Share on other sites More sharing options...
fenway Posted November 9, 2010 Share Posted November 9, 2010 say the remainder was 19 , it needs to show add 20 , 1 , 2 3 . so it must start back at one Why? Link to comment https://forums.phpfreaks.com/topic/217828-mysql-help-with-query/#findComment-1132253 Share on other sites More sharing options...
jdavidbakr Posted November 11, 2010 Share Posted November 11, 2010 Maybe build an 'in' clause - i.e. $i = the remainder $statement = "select * from ads where id in (".(($i+1)%20).",".(($i+2)%20).",".(($i+3)%20).",".(($i+4)%20).")"; Link to comment https://forums.phpfreaks.com/topic/217828-mysql-help-with-query/#findComment-1133217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.