jerastraub Posted September 28, 2006 Share Posted September 28, 2006 I am trying to make product page that display 3 columns with 9 products per page. I also want it to display something like: <<prev 1 2 3 next >>>. But I want it to count the number of products. So if there are only 18 product in the category, it will only show << prev 1 2 next >> and on page 2 show the next 9 products.Here is my code I keep getting an error of:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/w21510/public_html/pluswomen/shoescats.php on line 199Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/w21510/public_html/pluswomen/shoescats.php on line 204and it shows all the products in the category below with no page numbers.[code]<? include("config.php"); ?><? // Sort products by Name as defaultif(!$sortby){ $sortby="ProductName"; } ?> <?if(!$start){$start = 0;}if(!$limit){$limit = $perpage;}$end=($start+$limit);$query = "SELECT * FROM womensproducts WHERE CategoryID='$cat'";$result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if($result && mysql_num_rows($result) > 0){ $i = 0; $max_columns = 3; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; // make sure we have a valid product // make sure we have a valid product// if($product != "" && $product != null) // temporary comment out echo <<<HTML <td align=center><table class="quick" width="100%" height="350" border="0" align=center cellspacing="0" cellpadding="0"> <tr> <td align=center><a href="http://pluswomen.thefreestuffvault.com/product-{$ProductID}.htm"><img src="{$BigImage}" border="0" height=180 alt="{$Name}"></a></td> </tr> <tr> <td align=center><p id="productname"><a href="http://pluswomen.thefreestuffvault.com/product-{$ProductID}.htm">{$ProductName}</A></p></td> </tr> <tr> <td align=center><font size="2">Price: {$prodPrice}</font><font color=red> Now: ${$prodSale}</td> </tr></table></td>HTML; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while} // end if results// clean up table - makes your code valid!if($i < $max_columns){ for($j=$i; $j<$max_columns;$j++) echo "";}$cat2 = urlencode($category);$prv = ($start-$limit);$nxt = ($start+$limit);if($prv < 0){$previous = "";}else {$previous = "<a href=\"http://pluswomen.thefreestuffvault.com/moreshoe-$cat2-$sortby-$prv-$limit.htm\"><<< Previous $limit Products</a>";}if(mysql_num_rows(mysql_query($sql)) < $nxt){$next = "";}else {$next = "<a href=\"http://pluswomen.thefreestuffvault.com/moreshoe-$cat2-$sortby-$nxt-$limit.htm\">Next $limit Products >>></a>";}if(mysql_num_rows(mysql_query($sql)) > $limit){echo "<br><table border=1 bordercolor=#999999 align=center width=90% bgcolor=#ffffff cellpadding=3 cellspacing=0><TR><TD align=center><b>$previous</b> <b>$next</b></font></TR></TD></table><P>";}mysql_free_result($result);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/ Share on other sites More sharing options...
alpine Posted September 28, 2006 Share Posted September 28, 2006 I can't see where you define $sql that mysql_num_rows() is checking - hense your two errors.[color=red](mysql_num_rows(mysql_query($sql)) < $nxt)[/color]It should probably be looking for $result.[color=blue](mysql_num_rows(mysql_query($result)) < $nxt)[/color]Anyhow, you need to have a second query to select with limit and offset to get the pagination to work[code]$result= mysql_query("SELECT * FROM womensproducts WHERE CategoryID='$cat'") or die(mysql_error());$result_main = mysql_query("SELECT * FROM womensproducts WHERE CategoryID='$cat' limit $start, $limit") or die(mysql_query());if(mysql_num_rows($result_main) > 0){ $i = 0; $max_columns = 3; while($row = mysql_fetch_array($result_main)) {[/code]and[code]if(mysql_num_rows($result) < $nxt){$next = "";}else {$next = "<a href=\"http://pluswomen.thefreestuffvault.com/moreshoe-$cat2-$sortby-$nxt-$limit.htm\">Next $limit Products >>></a>";}if(mysql_num_rows($result) > $limit){[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-100368 Share on other sites More sharing options...
jerastraub Posted September 28, 2006 Author Share Posted September 28, 2006 Even with changing this, i still get the same error. I have to be missing something here. Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-100371 Share on other sites More sharing options...
alpine Posted September 28, 2006 Share Posted September 28, 2006 Did you get my edit before you tested ? Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-100382 Share on other sites More sharing options...
jerastraub Posted September 28, 2006 Author Share Posted September 28, 2006 Hey Alpine, I added the code you posted and now i get a blank page, no errors no results. :([code]<? include("config.php"); ?><? // Sort products by Name as defaultif(!$sortby){ $sortby="ProductName"; } ?> <?if(!$start){$start = 0;}if(!$limit){$limit = $perpage;}$end=($start+$limit);$query = "SELECT * FROM womensproducts WHERE CategoryID='$cat'";$result= mysql_query("SELECT * FROM womensproducts WHERE CategoryID='$cat'") or die(mysql_error());$result_main = mysql_query("SELECT * FROM womensproducts WHERE CategoryID='$cat' limit $start, $limit") or die(mysql_query());if(mysql_num_rows($result_main) > 0){ $i = 0; $max_columns = 3; while($row = mysql_fetch_array($result_main)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; // make sure we have a valid product // make sure we have a valid product// if($product != "" && $product != null) // temporary comment out echo <<<HTML <td align=center><table class="quick" width="100%" height="350" border="0" align=center cellspacing="0" cellpadding="0"> <tr> <td align=center><a href="http://pluswomen.thefreestuffvault.com/product-{$ProductID}.htm"><img src="{$BigImage}" border="0" height=180 alt="{$Name}"></a></td> </tr> <tr> <td align=center><p id="productname"><a href="http://pluswomen.thefreestuffvault.com/product-{$ProductID}.htm">{$ProductName}</A></p></td> </tr> <tr> <td align=center><font size="2">Price: {$prodPrice}</font><font color=red> Now: ${$prodSale}</td> </tr></table></td>HTML; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while} // end if results// clean up table - makes your code valid!if($i < $max_columns){ for($j=$i; $j<$max_columns;$j++) echo "";}$cat2 = urlencode($category);$prv = ($start-$limit);$nxt = ($start+$limit);if($prv < 0){$previous = "";}else {$previous = "<a href=\"http://pluswomen.thefreestuffvault.com/moreshoe-$cat2-$sortby-$prv-$limit.htm\"><<< Previous $limit Products</a>";}if(mysql_num_rows($result) < $nxt){$next = "";}else {$next = "<a href=\"http://pluswomen.thefreestuffvault.com/moreshoe-$cat2-$sortby-$nxt-$limit.htm\">Next $limit Products >>></a>";}if(mysql_num_rows($result) > $limit){echo "<br><table border=1 bordercolor=#999999 align=center width=90% bgcolor=#ffffff cellpadding=3 cellspacing=0><TR><TD align=center><b>$previous</b> <b>$next</b></font></TR></TD></table><P>";}mysql_free_result($result);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-100471 Share on other sites More sharing options...
alpine Posted September 28, 2006 Share Posted September 28, 2006 i (did it again) wrote wrong error check in the $result_main, should be "or die(mysql_error());"See if that gives anything.....Your $perpage is defined elsewhere i assume ? Also you are running relying on register globals to be ON, but i assume this is your current php setupYou can ditch the $query since that is not used, replaced by $result Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-100505 Share on other sites More sharing options...
jerastraub Posted September 28, 2006 Author Share Posted September 28, 2006 I changed the sql error statement. Also yes my $perpage is defined in my onfig.php which is set to 7. Also I checked phpinfo and my current setting is indeed register_globals On.I also removed [code]$query = "SELECT * FROM womensproducts WHERE CategoryID='$cat'";[/code]from [code]$query = "SELECT * FROM womensproducts WHERE CategoryID='$cat'";$result= mysql_query("SELECT * FROM womensproducts WHERE CategoryID='$cat'") or die(mysql_error());$result_main = mysql_query("SELECT * FROM womensproducts WHERE CategoryID='$cat' limit $start, $limit") or die(mysql_error());[/code]And I am still only getting a blank page :(I use:[code]<?phpinclude ("config.php");?><?php$query = "SELECT * FROM womensproducts WHERE CategoryID='9272' limit 9";$result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if($result && mysql_num_rows($result) > 0){ $i = 0; $max_columns = 3; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; // make sure we have a valid product // make sure we have a valid product// if($product != "" && $product != null) // temporary comment out echo <<<HTML <td align=center><table class="quick" width="100%" height="350" border="0" align=center cellspacing="0" cellpadding="0"> <tr> <td align=center><a href="http://pluswomen.thefreestuffvault.com/product-{$ProductID}.htm"><img src="{$BigImage}" border="0" height=180 alt="{$Name}"></a></td> </tr> <tr> <td align=center><p id="productname"><a href="http://pluswomen.thefreestuffvault.com/product-{$ProductID}.htm">{$ProductName}</A></p></td> </tr> <tr> <td align=center><font size="2">Price: {$prodPrice}</font><font color=red> Now: ${$prodSale}</td> </tr></table></td>HTML; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while} // end if results// clean up table - makes your code valid!if($i < $max_columns){ for($j=$i; $j<$max_columns;$j++) echo "";} ?>[/code] for just displaying 9 products in 3 column format, but when I start adding code for the: [code]<< prev 1 2 3 next >>>[/code]that is when i start having problems. Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-100516 Share on other sites More sharing options...
jerastraub Posted September 29, 2006 Author Share Posted September 29, 2006 Anyone have any ideas, I have been trying to troubleshoot this and nothing! Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-100664 Share on other sites More sharing options...
HuggieBear Posted September 29, 2006 Share Posted September 29, 2006 Can you provide me with the full code for the page you're trying to paginate, and also a list of variable names and values that you're getting from the 'included' config file?Let's help you get this cleared up for you :DRegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-100742 Share on other sites More sharing options...
jerastraub Posted September 29, 2006 Author Share Posted September 29, 2006 Okay, Here's my page code:[code]<? include("config.php"); ?><? // Sort products by Name as defaultif(!$sortby){ $sortby="ProductName"; } ?> <?if(!$start){$start = 0;}if(!$limit){$limit = $perpage;}$end=($start+$limit);$result= mysql_query("SELECT * FROM womensproducts WHERE CategoryID='$cat'") or die(mysql_error());$result_main = mysql_query("SELECT * FROM womensproducts WHERE CategoryID='$cat' limit $start, $limit") or die(mysql_error());if(mysql_num_rows($result_main) > 0){ $i = 0; $max_columns = 3; while($row = mysql_fetch_array($result_main)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; // make sure we have a valid product // make sure we have a valid product// if($product != "" && $product != null) // temporary comment out echo <<<HTML <td align=center><table class="quick" width="100%" height="350" border="0" align=center cellspacing="0" cellpadding="0"> <tr> <td align=center><a href="http://pluswomen.thefreestuffvault.com/product-{$ProductID}.htm"><img src="{$BigImage}" border="0" height=180 alt="{$Name}"></a></td> </tr> <tr> <td align=center><p id="productname"><a href="http://pluswomen.thefreestuffvault.com/product-{$ProductID}.htm">{$ProductName}</A></p></td> </tr> <tr> <td align=center><font size="2">Price: {$prodPrice}</font><font color=red> Now: ${$prodSale}</td> </tr></table></td>HTML; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while} // end if results// clean up table - makes your code valid!if($i < $max_columns){ for($j=$i; $j<$max_columns;$j++) echo "";}$cat2 = urlencode($category);$prv = ($start-$limit);$nxt = ($start+$limit);if($prv < 0){$previous = "";}else {$previous = "<a href=\"http://pluswomen.thefreestuffvault.com/moreshoe-$cat2-$sortby-$prv-$limit.htm\"><<< Previous $limit Products</a>";}if(mysql_num_rows($result) < $nxt){$next = "";}else {$next = "<a href=\"http://pluswomen.thefreestuffvault.com/moreshoe-$cat2-$sortby-$nxt-$limit.htm\">Next $limit Products >>></a>";}if(mysql_num_rows($result) > $limit){echo "<br><table border=1 bordercolor=#999999 align=center width=90% bgcolor=#ffffff cellpadding=3 cellspacing=0><TR><TD align=center><b>$previous</b> <b>$next</b></font></TR></TD></table><P>";}mysql_free_result($result);?>[/code]This is my config.php:[code]<?// How Many Products Do You Want To Show Per Page On Your (Category Pages) Pages?$perpage = "7";// Do You Want Your Links To Open In a New Window When Visitors Leave Your Site?$target = "blank"; //Change to: "top"; to stay in the same browser // Do Not Edit Below This Line !!!$dbhost = "localhost";$dbuser = "w21510_jerastrau";$dbname = "w21510_allthefreestuffvaultsubdomain";$dbpass = "spunkee1";$db = mysql_connect("$dbhost","$dbuser","$dbpass");mysql_select_db("$dbname",$db);?>[/code]Varaibles I need to pulled for each product are:$prodSale$ProductID$ProductName $prodPrice$BigImage$NameI am trying to get a display of 3 columns wide by 3 rows. With navigation of << prev 1 2 next >>>, which would change depending on how many products are in that category. Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-100868 Share on other sites More sharing options...
HuggieBear Posted September 29, 2006 Share Posted September 29, 2006 I've almost finished the code and it looks good, but I have a question, why if you want three rows of three (nine in total) does your $perpage variable show a value of 7... lolI'd recoment changing $perpage to a value of max_row * max_col, and I'll include that in my code.Also, I'm trying a few different methods, can you possibly let me know the order your columns are in in the database?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-100910 Share on other sites More sharing options...
HuggieBear Posted September 29, 2006 Share Posted September 29, 2006 Give this a try and let me know how you get on. It was written on the fly and as such is untested, so don't dispair if it doesn't work, just let me know what the error is...There's a commented line in there where I need you to add a default category.[code]<?phpinclude("config.php");// Sort products by Name as default//if(!$sortby){ $sortby="ProductName"; } // Commented out as it's not used anywhere, it was incorrect in your links// Select total results for pagination$result = mysql_query("SELECT count(*) FROM womensproducts WHERE CategoryID = '$cat'");$num_records = mysql_result($result,0,0);// Set maximum number of rows and columns$max_num_rows = 3;$max_num_columns = 3;$per_page = $max_num_columns * $max_num_rows;// Work out how many pages there are$total_pages = ceil($num_records / $per_page);// Get the current page numberif (isset($_GET['page'])) $page = $_GET['page']; else $page = 1;// Get the category or assign a defailtif (isset($_GET['cat'])) $cat = $_GET['cat']; else $cat = "default"; // enter a default category here// Work out the limit offset$start = ($page - 1) * $per_page;// Run your query with the limit and offset in place$result_main = mysql_query("SELECT * FROM womensproducts WHERE CategoryID='$cat' limit $start, $per_page") or die(mysql_error());$num_columns = ceil(mysql_num_rows($result_main)/$max_num_rows);$num_rows = ceil(mysql_num_rows($result_main)/$num_columns);// Lets start creating tables and echoing codeecho "<table>\n";$c = 0;while($row = mysql_fetch_array($result_main)){ // make the variables easy to deal with extract($row); // open row if counter is zero if($c == 0){ echo "<tr>"; } // echo the individual cells echo <<<HTML <td align=center><table class="quick" width="100%" height="350" border="0" align=center cellspacing="0" cellpadding="0"> <tr> <td align=center><a href="http://pluswomen.thefreestuffvault.com/product-{$ProductID}.htm"><img src="{$BigImage}" border="0" height=180 alt="{$Name}"></a></td> </tr> <tr> <td align=center><p id="productname"><a href="http://pluswomen.thefreestuffvault.com/product-{$ProductID}.htm">{$ProductName}</A></p></td> </tr> <tr> <td align=center><font size="2">Price: {$prodPrice}</font><font color=red> Now: ${$prodSale}</td> </tr></table></td>HTML; // increment counter - if counter = max columns, reset counter and close row if(++$c == $max_columns){ echo "</tr>"; $c = 0; }}// clean up table - makes your code valid!if($c < $max_columns){ for($e = $c; $e < $max_columns; $e++){ echo " "; }}// If there's more than one page, show linksif ($total_pages > 1){ echo <<<HTML <table> <tr> <td align="center">Please select a page</td> </tr> <tr> <td align="center">HTML; // Build the previous link if ($page > 1){ $prev = ($page -1); echo "<a href=\"{$_SERVER['PHP_SELF']}?cat=$cat&page=$prev\"><< Previous</a> "; } // Build the page numbers for($i = 1; $i <= $total_pages; $i++){ if($page == $i){ echo "$i "; } else { echo "<a href=\"{$_SERVER['PHP_SELF']}?cat=$cat&page=$i\">$i</a> "; } } // Build the next link if ($page < $total_pages){ $next = ($page +1); echo "<a href=\"{$_SERVER['PHP_SELF']}?cat=$cat&page=$prev\">Next >></a>"; } // Close off the links echo <<<HTML </td> </tr> </table>HTML;}?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101006 Share on other sites More sharing options...
jerastraub Posted September 29, 2006 Author Share Posted September 29, 2006 Huggybear, It almost works,Here is the page that i put the code, so you can see what it is displaying. http://pluswomen.thefreestuffvault.com/testcolumns2.html?cat=9245I also made a txt version so you can see the code behind:http://pluswomen.thefreestuffvault.com/testcolumns2php.txtIt just displays the products in one row.After changing :[code] echo "<a href=\"{$_SERVER['PHP_SELF']}?cat=$cat&page=$prev\">Next >></a>";[/code]to [code]echo "<a href=\"{$_SERVER['PHP_SELF']}?cat=$cat&page=$next\">Next >></a>";[/code]the next feature worked perfectly.All that needs to be found out it it to get it in 3 columns and 3 rows!Also the LIMIT 7 was a typo on my part, sry if that made it confusing. Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101050 Share on other sites More sharing options...
HuggieBear Posted September 29, 2006 Share Posted September 29, 2006 ok, try changing this...[code] // increment counter - if counter = max columns, reset counter and close row if(++$c == $max_columns){ echo "</tr>"; $c = 0; }}// clean up table - makes your code valid!if($c < $max_columns){ for($e = $c; $e < $max_columns; $e++){ echo " "; }}[/code]To this:[code] // increment counter - if counter = max columns, reset counter and close row if(++$c == $max_num_columns){ echo "</tr>"; $c = 0; }}// clean up table - makes your code valid!if($c < $max_num_columns){ for($e = $c; $e < $max_num_columns; $e++){ echo " "; }}[/code]Did you see that by adding in a default page and category, you can go direct to http://pluswomen.thefreestuffvault.com/testcolumns2.html without any variables in the url and still get a valid page up.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101057 Share on other sites More sharing options...
jerastraub Posted September 29, 2006 Author Share Posted September 29, 2006 Your, awesome Huggybear.I actually use mod_rewrites to get rid of the ?cat=4644.Where my url's actually look like http://pluswomen.thefreestuffvault.com/clothing-9250.htmwhich would normally be http://pluswomen.thefreestuffvault.com//clothingcats.php?cat=9250.Thanks so much.I finally don't have to just settle for a page nav of just <<< Previous 7 Products Next 7 Products >>>. This isn't customer friendly cause they don't know how many products their are.Also I have another question about getting the nav on top and bottom of the results.Kinda like: << Previous 1 2 3 4 Next >>Picture Picture Picture Picture Picture Picture Picture Picture Picture << Previous 1 2 3 4 Next >>is this a deficult task? Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101070 Share on other sites More sharing options...
HuggieBear Posted September 29, 2006 Share Posted September 29, 2006 Not at all, just paste this...[code]// If there's more than one page, show linksif ($total_pages > 1){ echo <<<HTML <table> <tr> <td align="center">Please select a page</td> </tr> <tr> <td align="center">HTML; // Build the previous link if ($page > 1){ $prev = ($page -1); echo "<a href=\"{$_SERVER['PHP_SELF']}?cat=$cat&page=$prev\"><< Previous</a> "; } // Build the page numbers for($i = 1; $i <= $total_pages; $i++){ if($page == $i){ echo "$i "; } else { echo "<a href=\"{$_SERVER['PHP_SELF']}?cat=$cat&page=$i\">$i</a> "; } } // Build the next link if ($page < $total_pages){ $next = ($page +1); echo "<a href=\"{$_SERVER['PHP_SELF']}?cat=$cat&page=$prev\">Next >></a>"; } // Close off the links echo <<<HTML </td> </tr> </table>HTML;}[/code]Between these two line...[code]$num_rows = ceil(mysql_num_rows($result_main)/$num_columns);<---- Here// Lets start creating tables and echoing code[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101073 Share on other sites More sharing options...
jerastraub Posted September 29, 2006 Author Share Posted September 29, 2006 I figured it out, Tks again huggy, you da man. Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101098 Share on other sites More sharing options...
jerastraub Posted September 29, 2006 Author Share Posted September 29, 2006 Okay, Found one problem. I rely on the $cat value to populate my pages, let's say I don't have any products in that category at this time and don't want to display a default value as this would confuse a customer.I get a "Division by zero" warning rather than it displaying:No Products In This Category - Please try another category!How do I fix this issue, as my datafeeds are downloaded everyday and one day there may be a product in a certain category and the next day none?I was thinking of adding something like :[code]if(mysql_num_rows(mysql_query($sql)) < 1){echo "No Products In This Category - Please try another category!";} else { $num_records = mysql_result($result,0,0); }}[/code]right before[code]// Select total results for pagination$result = mysql_query("SELECT count(*) FROM womensproducts WHERE CategoryID = '$cat'");[/code]but this give even more errors, but does display "No Products In This Category - Please try another category!"I even tried adding:[code]$sql = "SELECT * FROM womensproducts WHERE CategoryID='$cat' "; if(mysql_num_rows(mysql_query($sql)) < 1){echo "No Products In This Category - Please try another category!";} else { $result = mysql_query("SELECT count(*) FROM womensproducts WHERE CategoryID = '$cat'"); }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101146 Share on other sites More sharing options...
HuggieBear Posted September 29, 2006 Share Posted September 29, 2006 ok, if you don't want to display a default category, then maybe something like this at the top of the page...[code]<?phpif (empty($_GET['cat'])){ header("Location: index.php");}?>[/code]This will redirect them to index.php if they don't provide a category, and we can do something else for if they provide a category, but there's no items in it.At the top of your page, insert this:[code]if ($num_records == 0){ echo "There are no records to display in the selected category, please select another\n"; exit;}[/code]Between these lines of code:[code]$num_records = mysql_result($result,0,0);<--- Insert here// Set maximum number of rows and columns[/code]This isn't very tidy or helpful, but it gives you the bare bones to add the flesh too ;)RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101180 Share on other sites More sharing options...
jerastraub Posted September 29, 2006 Author Share Posted September 29, 2006 wow, I can't believe I didn't think of just adding the[code]exit;[/code] at the end. Sometime it's the little things that get over looked!Thanks again Huggy! Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101188 Share on other sites More sharing options...
HuggieBear Posted September 29, 2006 Share Posted September 29, 2006 No problem, any more questions before I become a bedtime bear?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101189 Share on other sites More sharing options...
jerastraub Posted September 30, 2006 Author Share Posted September 30, 2006 Nope,My site is working like a gem now.If you want to see the code at work, please go to:http://pluswomen.thefreestuffvault.com/ Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101215 Share on other sites More sharing options...
HuggieBear Posted September 30, 2006 Share Posted September 30, 2006 Looks good, I'd correct one thing though...If you look at this page: http://pluswomen.thefreestuffvault.com/clothing-9245.htmYou'll see that the <<Previous 1 2 3 4 Next>> aren't quite evenly spaced. It's only a tiny thing, but I'm anal, and it seems a shame after after all this hard work to not have it 'Perfect'.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22396-columned-results-with-next-previous/#findComment-101329 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.