nezbo Posted July 5, 2007 Share Posted July 5, 2007 hi all I have nearly finished the code and i cant seem to get it to display the <prev 1 2 3 4 etc.. on the pages after the first page. e.g. I click on next and it works fine but there is nothing there to click on the next page(s)... there is 5 pages on the first page that can be clicked on but nothing on the rest of the pages, all the data is there but no <prev 1 2 3 4 5 next> Any ideas ? $display = 10; if (isset($_GET['np'])) { $num_pages = $_GET['np']; } else { $query = "SELECT COUNT(*) FROM job WHERE Completed='Yes' ORDER BY JobID DESC" or die("oh dear" . mysql_error()); $result = mysql_query($query); $row2 = mysql_fetch_array($result, MYSQL_NUM); $num_records = $row2[0]; } if ($num_records > $display) { $num_pages = ceil ($num_records/$display); } else { $num_pages = 1; } if (isset($_GET["s"])) { $start = $_GET["s"]; } else { $start = 0; } $completedJobs = "SELECT * FROM job WHERE Completed='Yes' ORDER BY JobID DESC LIMIT $start, $display" or die("crap!!!" . mysql_error()); $result2 = mysql_query($completedJobs); echo "<table border=1 align = center width=90%><tr>"; echo "<tr><td colspan=10 align=center><h2>Check Jobs</h2><tr><td>"; echo " <tr bgcolor = #acacac> <td>Call ID <td>PCIU Number <td>Reported By <td>Passed To <td>Job Completed <td>Problem Discription <td>Outcome <td>Date <td>Time <td>Site Name"; $bgcolour = "#ffffff"; while ($row = mysql_fetch_array($result2, MYSQL_ASSOC)) { if ($bgcolour == "#ffffff") { echo "<tr bgcolor = #ffffff> <td><a href=editJob.php?job_identifier=$row[JobID] >$row[JobID] </a></td> <td align=left>$row[PCIUno]</td> <td align=left>$row[RepBy]</td> <td align=left>$row[PassedTo]</td> <td align=left>$row[Completed]</td> <td align=left>$row[Problem]</td> <td align=left>$row[OutCome]</td> <td align=left>$row[callDate]</td> <td align=left>$row[callTime]</td> <td align=left>$row[site]</td> </tr>"; $bgcolour = "#ececec"; } else { echo "<tr bgcolor = #ececec> <td><a href=editJob.php?job_identifier=$row[JobID] >$row[JobID] </a></td> <td align=left>$row[PCIUno]</td> <td align=left>$row[RepBy]</td> <td align=left>$row[PassedTo]</td> <td align=left>$row[Completed]</td> <td align=left>$row[Problem]</td> <td align=left>$row[OutCome]</td> <td align=left>$row[callDate]</td> <td align=left>$row[callTime]</td> <td align=left>$row[site]</td> </tr>"; $bgcolour = "#ffffff"; } } if ($num_pages > 1) { echo "<br /><p>"; $current_page = ($start/$display) + 1; if ($current_page != 1) { echo "<a href=\"checkCompletedJobs.php?s=" . ($start - $display) . "&np=" . $num_pages . "\">Previous</a> "; } for ($i = 1; $i <= $num_pages; $i++) { if($i != $current_page) { echo "<a href=\"checkCompletedJobs.php?s=" . ($display * ($i - 1)) . "&np=" . $num_pages . "\">" . $i . "</a> "; } else { echo $i . ""; } } if ($current_page != $num_pages) { echo "<a href=\"checkCompletedJobs.php?s=" . ($start + $display) . "&np=" . $num_pages . "\">Next</a>"; } } Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/ Share on other sites More sharing options...
BillyBoB Posted July 5, 2007 Share Posted July 5, 2007 if you would like i have developed a pagination function which is really easy to insert into your coding. there is a lot of lines with it but it does work in every situation. if you would like it just ask i will monitor this post. Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290264 Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 I take it that script I posted yesterday was a bit much? Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290266 Share on other sites More sharing options...
BillyBoB Posted July 5, 2007 Share Posted July 5, 2007 Yesideez what do you mean? if you have aim mine is: BillyBoB66969 this is the only way i will post it so i can keep it a little more private Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290273 Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 I posted a complete script yesterday which had dynamic pageinating functions and an index along with "Next" and "Previous" to almost the exact same question yesterday. I'm thinking my script was a little too much. Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290287 Share on other sites More sharing options...
BillyBoB Posted July 5, 2007 Share Posted July 5, 2007 ok well i will just go ahead and post the code and how to use it: <?php function pagination($h,$get,$page,$z) { $g = ceil($h/$z); $d = 0; $u = 0; $o = 0; if($g>1) { while($d!=$g) { $d++; if($get) { if($get==$g){ $c = $get - 4; if($c!=0) { $o = 1; } if($o==0) { $d = $get - 3; $o = 1; } if($d==$get) { echo("<b>[$d]</b>"); echo(" "); }else{ $c = $get - 4; if($c!=0) { echo("<a href=\"$page&pg=$d\">$d</a>"); echo(" "); }else{ if($u==0) { echo("<a href=\"$page&pg=1\">1</a>"); echo(" ... "); $u = 1; }else{ echo("<a href=\"$page&pg=$d\">$d</a>"); echo(" "); } } } }else{ if($d==$get) { echo("<b>[$d]</b>"); echo(" "); }else{ if($get==1) { if($d<4) { echo("<a href=\"$page&pg=$d\">$d</a>"); echo(" "); }else{ echo("... <a href=\"$page&pg=$g\">$g</a>"); $d = $g; } }else{ $a = $get - 4; $b = $get + 2; if($a>0) { if($d==$get) { echo("<b>[$d]</b>"); echo(" "); }else{ if($u==0) { echo("<a href=\"$page&pg=1\">1</a>"); echo(" ... "); $u = 1; }else{ if($o==0) { $d = $get - 2; $o = 1; } if($get+3==$d) { if($b<$g-1) { echo(" ... "); echo("<a href=\"$page&pg=$g\">$g</a>"); $d = $g; }else{ echo("<a href=\"$page&pg=$d\">$d</a>"); echo(" "); } }else{ echo("<a href=\"$page&pg=$d\">$d</a>"); echo(" "); } } } }else{ if($get+3==$d) { if($b<$g-1) { echo(" ... "); echo("<a href=\"$page&pg=$g\">$g</a>"); $d = $g; }else{ echo("<a href=\"$page&pg=$d\">$d</a>"); echo(" "); } }else{ echo("<a href=\"$page&pg=$d\">$d</a>"); echo(" "); } } } } } }else{ if($d==1) { echo("<b>[$d]</b>"); echo(" "); }else{ if($d<4) { echo("<a href=\"$page&pg=$d\">$d</a>"); echo(" "); }else{ echo("... <a href=\"$page&pg=$g\">$g</a>"); $d = $g; } } } } }else{ echo("<b>[1]</b>"); } } ?> this is quite a big function but it is very effective. to use it you must have this at the begining of the page or require_once from a functions.php page <?php pagination($h,$_GET['pg'],"yourpage.php?",5); ?> ok the $h has to be how many rows you have exaple(this isnt good coding just a ex.) while("SELECT * FROM info") { $h++; } the $_GET['pg'] is the page number you are on i would keep this system on a GET cmd of pg the page is the page which can include other GET cmds like action=view you would enter yourpage.php?action=view and so on the 5 is the intraval like how many you want on a page this was an extra addition to the code so that i could use it on multiple sites. If you would like any more info on this please just ask PM me maybe Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290294 Share on other sites More sharing options...
nezbo Posted July 5, 2007 Author Share Posted July 5, 2007 hehe, i had allready done most of the code to get it to this stage, but i was in 2 minds wether to use your code... I take it that script I posted yesterday was a bit much? Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290324 Share on other sites More sharing options...
BillyBoB Posted July 5, 2007 Share Posted July 5, 2007 so what does this mean can i ask which you decided to go with? Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290327 Share on other sites More sharing options...
nezbo Posted July 5, 2007 Author Share Posted July 5, 2007 I think i am going to stick with my orginal code... so dose any one know how to get it to work? so what does this mean can i ask which you decided to go with? Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290329 Share on other sites More sharing options...
BillyBoB Posted July 5, 2007 Share Posted July 5, 2007 ok in order for me to really help i would need to see this script in action can you hook me up with a link to where you have it? Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290334 Share on other sites More sharing options...
sasa Posted July 5, 2007 Share Posted July 5, 2007 change name 'no problem' to 'no_problem' Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290338 Share on other sites More sharing options...
nezbo Posted July 5, 2007 Author Share Posted July 5, 2007 Cool Here is the web link http://www.eastlancsmedicalservices.co.uk/checkCompletedJobs.php ok in order for me to really help i would need to see this script in action can you hook me up with a link to where you have it? Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290339 Share on other sites More sharing options...
nezbo Posted July 5, 2007 Author Share Posted July 5, 2007 sorry i dont get it ??? ??? change name 'no problem' to 'no_problem' Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290341 Share on other sites More sharing options...
BillyBoB Posted July 5, 2007 Share Posted July 5, 2007 i dont see how the code you gave us can make that links code the np= isnt in your code at all.... Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290342 Share on other sites More sharing options...
nezbo Posted July 5, 2007 Author Share Posted July 5, 2007 the code i sent you is only making the main body of the script i am including hedders and footers etc... so the code is the table and the numbers etc... i dont see how the code you gave us can make that links code the no problem= isnt in your code at all.... Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290349 Share on other sites More sharing options...
sasa Posted July 5, 2007 Share Posted July 5, 2007 remove np=7 from your link, you calculate from s in which page you are i see in your page that you don't use no problem (it is no problem, i think) name with space is not regular from form field, convert space to '_' Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290362 Share on other sites More sharing options...
nezbo Posted July 5, 2007 Author Share Posted July 5, 2007 im easly confused and that has done the trick :'( remove no problem=7 from your link, you calculate from s in which page you are i see in your page that you don't use no problem (it is no problem, i think) name with space is not regular from form field, convert space to '_' Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290367 Share on other sites More sharing options...
sasa Posted July 5, 2007 Share Posted July 5, 2007 is it work now? Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290369 Share on other sites More sharing options...
nezbo Posted July 5, 2007 Author Share Posted July 5, 2007 It's still not working :'( is it work now? Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290414 Share on other sites More sharing options...
sasa Posted July 5, 2007 Share Posted July 5, 2007 remove part np=blah from your link try use link http://www.eastlancsmedicalservices.co.uk/checkCompletedJobs.php?s=10 Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290430 Share on other sites More sharing options...
BillyBoB Posted July 5, 2007 Share Posted July 5, 2007 all of the pages work without the np=blah except they have a 7 infront of the Previous Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290435 Share on other sites More sharing options...
nezbo Posted July 5, 2007 Author Share Posted July 5, 2007 It seams to be working now yippee. i thought you was just bullying my with the "no Problem" thing but it turns out i was just confused and you are all genouses Cheers all of the pages work without the no problem=blah except they have a 7 infront of the Previous Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290446 Share on other sites More sharing options...
sasa Posted July 5, 2007 Share Posted July 5, 2007 i see that you remove 7 in front this forum convert'np' to np if confused me Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290453 Share on other sites More sharing options...
BillyBoB Posted July 5, 2007 Share Posted July 5, 2007 please mark this as solved Link to comment https://forums.phpfreaks.com/topic/58514-pages-help-again/#findComment-290457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.