hbalagh Posted December 25, 2007 Share Posted December 25, 2007 I think I almost have this i have it so it only shows 12 images on the first page of each category but can't figure out how the link should be and get it to work.. i've done this before on another site but it didn't have categories to deal with, the code is a little messy right now.. but hoping someone can help me on this Thanks <?php include ("includes/db.conf.php"); include ("includes/connect.inc.php");include ("header.php"); if (isset($_GET['cat'])){ $query = "SELECT * from products where category='$_GET[cat]' "; $mysqlresult = mysql_query($query); $queryc=mysql_query("select * from categories where id='$_GET[cat]' "); $rowqueryc=mysql_fetch_array($queryc); echo "<div id='featureindex'>"; echo "<h3>$rowqueryc[name]</h3>"; } $qry = mysql_query (" SELECT * FROM `products` where category='$_GET[cat]'"); if ($row=mysql_fetch_array($qry)) { do { $sName= $row["name"]; $sphoto= $row["photo"]; $sdescription= $row["description"]; } while ($row = mysql_fetch_array($qry)); } $limit = 12; $query_count = "SELECT count(*) FROM `products` where category='$_GET[cat]'"; $result_count = mysql_query($sName); $totalrows = mysql_num_rows($qry); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM `products` where category='$_GET[cat]' LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } while($row = mysql_fetch_array($result)){ echo "<div id='feature'><a href='product.php?product=$row[id]'><div id='productborder'><img src='images/thumbs/$row[photo]' border=0></div></a>"; echo($row["name"]); echo "</div>\n"; } echo "<br />\n"; $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"productlist.php?cat=$rowqueryc[id]page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"productlist.php?cat=$rowqueryc[id]page=$i\">$i</a> "); } echo "</div>\n"; } mysql_free_result($result); include_once 'footer.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/83126-pagination/ Share on other sites More sharing options...
Northern Flame Posted December 25, 2007 Share Posted December 25, 2007 well i found a mistake on your script on all the sql commands you have something like this: "SELECT * FROM categories WHERE id='$_GET[cat]'" you are forgetting the single quotes around the word cat try making it a variable and do something like $cat = $_GET['cat']; $change_queries_to = mysql_query("SELECT * FROM categories WHERE id='$cat'"); Quote Link to comment https://forums.phpfreaks.com/topic/83126-pagination/#findComment-422823 Share on other sites More sharing options...
tibberous Posted December 25, 2007 Share Posted December 25, 2007 Can also be: $change_queries_to = mysql_query("SELECT * FROM categories WHERE id='{$_GET['cat']}'"); Quote Link to comment https://forums.phpfreaks.com/topic/83126-pagination/#findComment-422831 Share on other sites More sharing options...
redarrow Posted December 25, 2007 Share Posted December 25, 2007 or <?php $queryc=mysql_query("select * from `categories` where `id`='".$_GET['cat']."' "); $rowqueryc=mysql_fetch_array($queryc); ?> Quote Link to comment https://forums.phpfreaks.com/topic/83126-pagination/#findComment-422833 Share on other sites More sharing options...
hbalagh Posted December 25, 2007 Author Share Posted December 25, 2007 thanks, but i still get confused by terminology the technical terms and after changing the below still can't get the links to work for it... or <?php $queryc=mysql_query("select * from `categories` where `id`='".$_GET['cat']."' "); $rowqueryc=mysql_fetch_array($queryc); ?> Quote Link to comment https://forums.phpfreaks.com/topic/83126-pagination/#findComment-422836 Share on other sites More sharing options...
Northern Flame Posted December 25, 2007 Share Posted December 25, 2007 did you follow the tutorial from phpfreaks? (if so, there have been people that have been having troubles with it and I have a fix for it) Quote Link to comment https://forums.phpfreaks.com/topic/83126-pagination/#findComment-422838 Share on other sites More sharing options...
hbalagh Posted December 25, 2007 Author Share Posted December 25, 2007 did you follow the tutorial from phpfreaks? (if so, there have been people that have been having troubles with it and I have a fix for it) yes for the most part Quote Link to comment https://forums.phpfreaks.com/topic/83126-pagination/#findComment-422841 Share on other sites More sharing options...
hbalagh Posted December 25, 2007 Author Share Posted December 25, 2007 can anyone offer anymore help on this Quote Link to comment https://forums.phpfreaks.com/topic/83126-pagination/#findComment-422931 Share on other sites More sharing options...
Northern Flame Posted December 25, 2007 Share Posted December 25, 2007 http://www.phpfreaks.com/forums/index.php/topic,172220.msg763400.html#msg763400 Quote Link to comment https://forums.phpfreaks.com/topic/83126-pagination/#findComment-422983 Share on other sites More sharing options...
hbalagh Posted December 26, 2007 Author Share Posted December 26, 2007 I am still very lost and can't get it to work Quote Link to comment https://forums.phpfreaks.com/topic/83126-pagination/#findComment-423773 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.