david212 Posted May 29, 2009 Share Posted May 29, 2009 Hi all. I wrote this piece of code: $sql="SELECT * FROM klm LIMIT ".$start.",".$limit.""; $xa=mysql_query($sql); $s=mysql_num_rows($xa); for($i=0;$i<$s;$i++){ $t=mysql_result($xa,$i,"mydata"); echo($t."<br>"); } if($_GET["page"]!=$pages){ echo("<a href=\"?page=".($_GET["page"]-1)."\">Prev</a> | "); } echo("<a href=\"?page=".($_GET["page"]+1)."\">Next</a>"); when i execute this code, the Preview appears with link, all i need is: disable preview at first (when page=0) and enable preview (when page=1,2, etc), disable Next (when there is no data to go on) For example, look at the image below, there is disabled the [1] page, i'd like to do something like this,. Thanx Link to comment https://forums.phpfreaks.com/topic/160170-need-help-with-next-and-preview-function/ Share on other sites More sharing options...
ngreenwood6 Posted May 29, 2009 Share Posted May 29, 2009 I think you have left some data out. What value does the $pages variable hold? Link to comment https://forums.phpfreaks.com/topic/160170-need-help-with-next-and-preview-function/#findComment-845091 Share on other sites More sharing options...
david212 Posted May 29, 2009 Author Share Posted May 29, 2009 yes, you are right: here it is: $limit=10; $pages=(int)($s/$limit); if($s%$limit>0){ $pages++; } $start=$limit*($_GET["page"]-1); Link to comment https://forums.phpfreaks.com/topic/160170-need-help-with-next-and-preview-function/#findComment-845157 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.