Msword Posted August 9, 2007 Share Posted August 9, 2007 How can i list mysql result in pages(Like result 1-25 on page 1, 26-50 page 2 and so on) currently using codes: while($row = mysql_fetch_array($result)) $result = mysql_query("SELECT pid, name,location, quest, membonly FROM pdatabase ORDER BY " . $by . " DESC"); Quote Link to comment https://forums.phpfreaks.com/topic/64009-solved-mysql-list-result-in-pages/ Share on other sites More sharing options...
Utech22 Posted August 9, 2007 Share Posted August 9, 2007 You need to create a recordset, that what I know so far. I have a project that I am doing and I will need to do that also; Quote Link to comment https://forums.phpfreaks.com/topic/64009-solved-mysql-list-result-in-pages/#findComment-319055 Share on other sites More sharing options...
Msword Posted August 9, 2007 Author Share Posted August 9, 2007 wouldn't there be some way i could just loop it? Quote Link to comment https://forums.phpfreaks.com/topic/64009-solved-mysql-list-result-in-pages/#findComment-319058 Share on other sites More sharing options...
teng84 Posted August 9, 2007 Share Posted August 9, 2007 i cant give you the full detail but your talking with sql paging and it work by pasing the value in the url like ?page=2 $x=$_GET['page']*10;//= 20 right? use this as the max value $y=$_GET['page']-1*10;//= 10 right? then use this as the min value then do something in your sql statement like select * from table limit $x,$y edited....... dont use it exactly use this as prototype only there are lots of code in the net Quote Link to comment https://forums.phpfreaks.com/topic/64009-solved-mysql-list-result-in-pages/#findComment-319059 Share on other sites More sharing options...
teng84 Posted August 9, 2007 Share Posted August 9, 2007 You need to create a recordset, that what I know so far. I have a project that I am doing and I will need to do that also; LOL what????? Quote Link to comment https://forums.phpfreaks.com/topic/64009-solved-mysql-list-result-in-pages/#findComment-319060 Share on other sites More sharing options...
Msword Posted August 9, 2007 Author Share Posted August 9, 2007 thanks again teng, thats what i needed yup, i just went to the mysql documentation and looked at it there. Quote Link to comment https://forums.phpfreaks.com/topic/64009-solved-mysql-list-result-in-pages/#findComment-319062 Share on other sites More sharing options...
Msword Posted August 9, 2007 Author Share Posted August 9, 2007 new problem, this is giving me syntax error. The variables are right, $page == 0. $by == pid. i want it to display 1-25 and i just gives error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.marja/msword/draftx.net/test/displaytable.php on line 54 if ($sort == "asc") { $result = mysql_query("SELECT pid, name,location, quest, membonly FROM pdatabase LIMIT '$page', 25 ORDER BY " . $by); } ELSE { $result = mysql_query("SELECT pid, name,location, quest, membonly FROM pdatabase LIMIT '$page', 25 ORDER BY " . $by . " DESC"); } technicly the error is when i'm displaying, but i know that works while($row = mysql_fetch_array($result)) Quote Link to comment https://forums.phpfreaks.com/topic/64009-solved-mysql-list-result-in-pages/#findComment-319076 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.