thaidomizil Posted October 8, 2011 Share Posted October 8, 2011 Hello, i'm trying to query mysql to show table contents, my code so far is this: mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM codes"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); to show content: <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"id"); $f2=mysql_result($result,$i,"code"); $f3=mysql_result($result,$i,"secret"); $f4=mysql_result($result,$i,"date"); $f5=mysql_result($result,$i,"ip"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td> </tr> Now this shows all the content from the table, what i want to have is 2 scripts which should work like this: Script1 to show table contents: ID1, ID2, ID4, ID5, ID7, ID8 and so on. Script2 to show table contents: ID3, ID6, ID9 and so on. Basically one that shows only every 3rd and skips 1 and 2, and another one that skips every 3rd. Is this possible ? Thanks ! Link to comment https://forums.phpfreaks.com/topic/248711-show-every-3rd-entry-from-table/ Share on other sites More sharing options...
thaidomizil Posted October 8, 2011 Author Share Posted October 8, 2011 Hello again i just googled a bit more and found this: select * from table where table.id mod 3 = 0; I guess i can use that for the every 3rd row page, but how would i solve the other one that should only 1,2 and skip 3 ? Link to comment https://forums.phpfreaks.com/topic/248711-show-every-3rd-entry-from-table/#findComment-1277297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.