Jump to content


  • Posts

  • Joined

  • Last visited

About HuggieBear

  • Birthday 06/14/1980

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    England, UK

HuggieBear's Achievements


Member (2/5)



  1. ok... That makes sense, disregard what I posted in the early hours of this morning, I thinks it's only serving to confuse matters further.  ;D Take the code that you have on page [color=green][url=http://www.plateauprofessionals.com/category-page2a.php?categoryid=4]category-page2a.php[/url][/color] as that code is almost right, and then just change the link at the bottom from this: [code=php:0]echo "<a class=\"body\" href=\"".$_SERVER['PHP_SELF']."?page=$i\">Page $i</a> "; [/code] To this: [code=php:0]echo "<a class=\"body\" href=\"".$_SERVER['PHP_SELF']."?categoryid=$cat_id&page=$i\">Page $i</a> "; [/code] and I think we'll finally be there. Regards Huggie
  2. [quote author=simcoweb link=topic=111171.msg453610#msg453610 date=1161156875] Unfortunately it's not paginating correctly. It just wants to display 5 results when there's 14 in the category. :( [/quote] I might be completely loosing the plot here, and if I am then somebody please shoot me as this is driving me insane, but the whole point of the pagination is that it only shows 5 results on the page, not 14! If you click on your [url=http://www.plateauprofessionals.com/category-page2a.php?categoryid=4]link[/url] up at the top of this page, it works fine, then when you click page 2 it doesn't work, but the link to page 2 is incorrect, as it doesn't contain the 'categoryid' in the URL.  Try this link to [url=http://www.plateauprofessionals.com/category-page2a.php?categoryid=4&page=2]page 2[/url] and then this link to [url=http://www.plateauprofessionals.com/category-page2a.php?categoryid=4&page=3]page 3[/url]. Have you made the modifications to the links that I suggested so that they include the 'categoryid' in the URL? Regards Huggie
  3. [quote author=simcoweb link=topic=111171.msg453290#msg453290 date=1161111168] Acutally the category id IS being passed in the URL as you can see in my example links: [url=http://www.plateauprofessionals.com/category-page2a.php?categoryid=4]http://www.plateauprofessionals.com/category-page2a.php?categoryid=4[/url] [/quote] Actually it's NOT!!!... Although I appreciate that you may have included your category id in the link that you included in your post to the forum, you have not included it in your code... Your code has this... [code] echo "<a class=\"body\" href=\"".$_SERVER['PHP_SELF']."?page=$i\">Page $i</a> "; [/code] Your code should look something like this... [code] echo "<a class=\"body\" href=\"".$_SERVER['PHP_SELF']."?categoryid=$cat_id&page=$i\">Page $i</a> "; [/code] Although I'm extremely pissed, I've had a go at changing the code you pasted, so change what you pasted to: [code] include 'dbconfig.php'; include 'header.php'; //connect to db mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); // Get category ID or set default $cat_id = is_numeric($_GET['categoryid']) ? $_GET['categoryid'] : 0; // Double check for a valid value // Get page ID or set default $page = isset($_GET['page']) ? $page = $_GET['page'] : $page = 1; // Define the number of results per page $max_results = 5; // Figure out the limit for the query based on the current page number. $from = (($page * $max_results) - $max_results); // Figure out the total number of results in DB: $sql = "SELECT COUNT(*) FROM members_cat WHERE categoryid='$cat_id'"; $result = mysql_query($sql); $total_results = mysql_num_results($result); // Figure out the total number of pages. Always round up using ceil() $total_pages = ceil($total_results / $max_results); // Grab data from plateau_pros, where the member has the specified category id $sql = "SELECT p.* FROM members_cat c, plateau_pros p WHERE c.categoryid='$cat_id' AND c.memberid=p.memberid LIMIT $from, $max_results"; $results = mysql_query($sql) or die(mysql_error()); $num_rows = mysql_num_rows($results); echo "<font class='bodytext'>There are <b>$num_rows</b> professionals in this category</font><br><br>\n"; // Build Page Number Hyperlinks echo "<center>Select a Page<br />"; for($i = 1; $i <= $total_pages; $i++){     echo " | ";     if(($page) == $i){         echo "Page $i ";         } else {             echo "<a class=\"body\" href=\"".$_SERVER['PHP_SELF']."?categoryid=$cat_id&page=$i\">Page $i</a> ";     } } echo "</center>"; if (empty($results)) {   echo "No profiles found in this category."; } else { while ($a_row= mysql_fetch_array($results)){ [/code] Let me know if you get an error. Regards Huggie
  4. OK, you're getting no results as you're not passing the category through the address. Change this at the bottom of the page: [code] echo "<a class=\"body\" href=\"".$_SERVER['PHP_SELF']."?page=$i\">Page $i</a> "; [/code] To this: [code] echo "<a class=\"body\" href=\"".$_SERVER['PHP_SELF']."?categoryid=$cat_id&page=$i\">Page $i</a> "; [/code] You must pass the category id through the URL too if you're using it in your query. Regards Huggie
  5. Sorry, got bogged down with my own project at the minute :( I'll take a look soon though, I've done something similar before, so it shouldn't be too hard to adapt the code. Huggie
  6. OK, the link you provided doesn't work I'm afraid.  As for the two variables in the SQL query, they're doing what they're meant to.  It should only be pulling 5 rows from the database, not 14.  Hence the pagination. Please can you post your whole code for that page as it currently stands.  Also, if you're able to put the example back on your site that would be helpful too. Regards Huggie
  7. Apologies for the delay... Here's the code, with comments, give it a try. [code]<?php // Connect to DB include('connect.php'); // Select total results for pagination $result = mysql_query('SELECT count(countryName) FROM tblCountry'); // This needs to be your query $num_records = mysql_result($result,0,0); // Set maximum number of rows and columns $max_num_rows = 2; $max_num_columns = 2; $per_page = $max_num_columns * $max_num_rows; // Work out how many pages there are going to be $total_pages = ceil($num_records / $per_page); // Get the current page number if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; // Work out the limit offset $start = ($page - 1) * $per_page; // Select the results we want including limit and offset $result = mysql_query("SELECT countryName FROM tblCountry ORDER BY countryName LIMIT $start, $per_page"); // Your query $num_columns = ceil(mysql_num_rows($result)/$max_num_rows); $num_rows = ceil(mysql_num_rows($result)/$num_columns); // Echo the results echo "<table border=\"2\">\n"; for ($r = 0; $r < $max_num_rows; $r++){ echo "<tr>\n"; for ($c = 0; $c < $max_num_columns; $c++){ $x = $r * $max_num_columns + $c; if ($x < mysql_num_rows($result)){                   $y = mysql_result($result, $x, 0); // This line outputs the results from your query                 }                 else {                   $y = "Coming Soon"; // This is what I put in the empty spaces                 } echo "<td>$y</td>"; } echo "</tr>\n"; } // Echo page numbers echo "</table>\n"; for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo " $i "; else echo " <a href=\"?page=$i\">$i</a> "; } ?>[/code] [size=8pt][color=red][b]Note:[/b][/color] If you have a 'where' clause in your main select statement, you should also include it in the pagination sql at the top of the page[/size] Regards Huggie
  8. Sorry dude, been busy, I'll get on the case now. Regards Huggie
  9. Oh, so you want it to open in a new window... That's not a php issue, it's HTML/Javascript Try googling for [url=http://www.google.co.uk/search?hl=en&q=javascript+%2B%22open+new+window%22&meta=&btnG=Google+Search]javascript +"open new window"[/url] Regards Huggie
  10. Yes, look at the second argument that fopen() accepts. Regards Huggie
  11. What do you mean by 'into javascript page' do you have a working example on a site somewhere?  Where did the idea come from? Regards Huggie
  12. Perfect, I'll take a look at this a little later.  A brief look would indicate that it's not going to be too difficult. Regards Huggie
  13. Give this a try: http://www.ups.com/content/us/en/resources/service/hardware/free.html?WT.svl=SubNav Regards Huggie
  14. OK, I have a huge deal on at work at the moment, but luckily for you, it's almost the weekend :) I'll post the code for you tomorrow, I might even try to integrate some of your code for you. Regards Huggie
  15. You provided the link to the .zip file, but as already stated, I'm not a member at codeproject.com If you provide me with the zip file that you downloaded from that site, I'll set it up. Regards Huggie
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.