bluedaniel Posted May 29, 2009 Share Posted May 29, 2009 Hello everyone, The webpage im trying to edit is http://www.whatcouldicook.com/vegetarian.php and the code for that is displayed below. the pagination script is: http://www.strangerstudios.com/sandbox/pagination/diggstyle_function.txt Basically I think I need to destroy the dreamweaver created query set and start a fresh, creating the variables needed for the pagination function ~ getPaginationString($page, $totalitems, $limit, $adjacents, $targetpage, $pagestring). Im going crazy looking at this code so if anyone could re-work it for me I would be eternally grateful. <?php require_once('wordpress/wp-config.php'); require_once('wordpress/wp-includes/wp-db.php'); require_once('wordpress/wp-includes/pluggable.php'); require('includes/connection.php'); require('includes/pagination.php'); require('_drawratingmenu.php');?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $currentPage = $_SERVER["PHP_SELF"]; $maxRows_dsRecipes = 15; $page = 0; if (isset($_GET['page'])) { $page = $_GET['page']; } $startRow_dsRecipes = $page * $maxRows_dsRecipes; mysql_select_db($database_dsRecipes, $dsRecipes); $query_dsRecipes = "SELECT Title, SmallDesc, id, picturesmall FROM recipes WHERE Vegetarian=1 ORDER BY Created_at DESC"; $query_limit_dsRecipes = sprintf("%s LIMIT %d, %d", $query_dsRecipes, $startRow_dsRecipes, $maxRows_dsRecipes); $dsRecipes = mysql_query($query_limit_dsRecipes, $dsRecipes) or die(mysql_error()); $row_dsRecipes = mysql_fetch_assoc($dsRecipes); if (isset($_GET['totalRows_dsRecipes'])) { $totalRows_dsRecipes = $_GET['totalRows_dsRecipes']; } else { $all_dsRecipes = mysql_query($query_dsRecipes); $totalRows_dsRecipes = mysql_num_rows($all_dsRecipes); } $totalPages_dsRecipes = ceil($totalRows_dsRecipes/$maxRows_dsRecipes)-1; $queryString_dsRecipes = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "page") == false && stristr($param, "totalRows_dsRecipes") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_dsRecipes = "&" . htmlentities(implode("&", $newParams)); } } $queryString_dsRecipes = sprintf("&totalRows_dsRecipes=%d%s", $totalRows_dsRecipes, $queryString_dsRecipes); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Vegetarian Recipes - What Could I Cook?</title> <link href="/_css/base.css" rel="stylesheet" type="text/css" /> <link href="/_css/recipelistings.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" language="javascript" src="js/behavior.js"></script> <script type="text/javascript" language="javascript" src="js/rating.js"></script> <link rel="SHORTCUT ICON" href="_images/favicon.ico" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="logoImage"></div> <div id="member"><?php if (!is_user_logged_in()) echo "<p><a href='http://www.whatcouldicook.com/wordpress/wp-login.php?redirect_to=http://www.whatcouldicook.com/share.php'>Log in</a> / <a href='/wordpress/wp-login.php?action=register'>Sign up</a></p>"; else echo "<p>Welcome <a href='/share.php'>" . wp_get_current_user()->user_nicename . "</a> | <a href='" . wp_logout_url() . "'>Logout</a></p>" ?> </div> <form method="get" id="searchform" action="/searchresults.php"> <fieldset> <label for="s" class="hide">Quick Search:</label> <input type="text" name="s" id="s" onfocus="if (this.value == 'E.g. Lemon Cheesecake') {this.value = '';}" onblur="if (this.value == '') {this.value = 'E.g. Lemon Cheesecake';}" value="E.g. Lemon Cheesecake"/> <button type="submit" id="searchsubmit" value="Search">Go</button> </fieldset> </form> <div id="advert"><img src="http://m1.2mdn.net/viewad/2019228/Voda_prepay_728x90.gif" alt="advert" width="468" height="60" /></div> <ul id="mainNav"> <li><a href="index.php">Home </a></li> <li class="selected"><a href="allRecipes.php" class="selected">Recipes </a></li> <li><a href="features.php">Features </a></li> <li><a href="/wordpress/index.php">Blogs </a></li> <li><a href="/forum">Forum </a></li> <li><a href="share.php">Share </a></li> <li><a href="shop.html">Shop </a></li> </ul> </div> <ul id="secondaryNav"> <li><a href="/allRecipes.php">All Recipes </a></li> <li><a href="#">Celeb Chefs </a></li> <li><a href="/cuisines.php">Cuisines </a></li> <li><a href="#">Occasions </a></li> <li><a href="#">Special Diets </a></li> <li><a href="/vegetarian.php">Vegetarian </a></li> <li><a href="#">Cheap Eats </a></li> </ul> <div id="content"> <div id="title"> <h2>There are <span class="num"><?php echo $totalRows_dsRecipes ?> </span> Vegetarian recipes, showing recipes <span class="num"><?php echo ($startRow_dsRecipes + 1) ?> to <?php echo min($startRow_dsRecipes + $maxRows_dsRecipes, $totalRows_dsRecipes) ?></span></h2> </div> <div class="love"> <div class="left"> <?php if ($page > 0) { // Show if not first page ?> <a href="<?php printf("%s?page=%d%s", $currentPage, 0, $queryString_dsRecipes); ?>" class="first">First</a> <a href="<?php printf("%s?page=%d%s", $currentPage, max(0, $page - 1), $queryString_dsRecipes); ?>" class="previous">Previous</a> <?php } // Show if not first page ?></div> <div class="right"><?php if ($page < $totalPages_dsRecipes) { // Show if not last page ?> <a href="<?php printf("%s?page=%d%s", $currentPage, min($totalPages_dsRecipes, $page + 1), $queryString_dsRecipes); ?>" class="next">Next</a> <a href="<?php printf("%s?page=%d%s", $currentPage, $totalPages_dsRecipes, $queryString_dsRecipes); ?>" class="last">Last</a> <?php } // Show if not last page ?></div> </div> <div id="searchfilter"> <h1>Recipe Index</h1> <form name="filter" method="post" action="/allRecipes.php"> <h2>Course</h2> <p><label><input name="checkbox" type="checkbox" id="checkbox1" value="1"/></label> Breakfast</p> <p><label><input name="checkbox" type="checkbox" id="checkbox2" value="2" /></label> Lunch</p> <p><label><input name="checkbox" type="checkbox" id="checkbox3" value="3" /></label> Dinner</p> <p><label><input name="dessert" type="checkbox" id="checkbox4" value="4" /></label> Dessert</p> <p><label><input name="checkbox2" type="checkbox" id="checkbox5" value="5" /></label> Snack</p> <h2>Time to Cook</h2> <p><label><input type="checkbox" name="checkbox3" id="checkbox6" /></label> Under 10 mins</p> <p><label><input type="checkbox" name="checkbox3" id="checkbox7" /></label> 10 - 30 mins</p> <p><label><input type="checkbox" name="checkbox3" id="checkbox8" /></label> 30 mins - 1 Hour</p> <p><label><input type="checkbox" name="dessert2" id="checkbox9" /></label> Between 1 - 2 Hours</p> <p><label><input type="checkbox" name="checkbox3" id="checkbox10" /></label> Over 2 hours</p> <h2>Special Considerations</h2> <p><label><input type="checkbox" id="checkbox11" value="1"/> </label> Vegetarian</p> <p><label><input type="checkbox" name="checkbox5" id="checkbox12" /></label> Vegan</p> <p><label><input type="checkbox" name="checkbox5" id="checkbox13" /></label> Cheap</p> <p><label><input type="checkbox" name="dessert3" id="checkbox14" /></label> Low-fat</p> <p><label><input type="checkbox" name="checkbox5" id="checkbox15" /></label> Low in salt</p> <h2>Author</h2> <p><label><input type="checkbox" name="checkbox4" id="checkbox16" /></label> User uploads</p> <p><label><input type="checkbox" name="checkbox6" id="checkbox17" /></label> Celebrity chef uploads</p><br/> </form> </div> <?php do { ?> <div class="method"> <h2><?php echo htmlentities($row_dsRecipes['Title']); ?></h2> <?php $recipeID = $row_dsRecipes['id']; echo rating_bar("$recipeID",'5', 'static'); ?> <p><a href="/recipe/<?php echo $row_dsRecipes['id']; ?>"><img src="<?php echo $row_dsRecipes['picturesmall']; ?>" name="recipeimg" class="recipeimg" alt="<?php echo htmlentities($row_dsRecipes['Title']); ?>" /></a></p> <p><?php echo htmlentities($row_dsRecipes['SmallDesc']); ?></p> <p><a href="/recipe/<?php echo $row_dsRecipes['id']; ?>" class="link">Click here to view</a></p> </div> <?php } while ($row_dsRecipes = mysql_fetch_assoc($dsRecipes)); ?> <br /> </div> <div class="love"> <div class="left"><?php if ($page > 0) { // Show if not first page ?> <a href="<?php printf("%s?page=%d%s", $currentPage, 0, $queryString_dsRecipes); ?>" class="first">First</a> <a href="<?php printf("%s?page=%d%s", $currentPage, max(0, $page - 1), $queryString_dsRecipes); ?>" class="previous">Previous</a> <?php } // Show if not first page ?></div> <div class="right"><?php if ($page < $totalPages_dsRecipes) { // Show if not last page ?> <a href="<?php printf("%s?page=%d%s", $currentPage, min($totalPages_dsRecipes, $page + 1), $queryString_dsRecipes); ?>" class="next">Next</a> <a href="<?php printf("%s?page=%d%s", $currentPage, $totalPages_dsRecipes, $queryString_dsRecipes); ?>" class="last">Last</a> <?php } // Show if not last page ?></div> </div> <div id="clear"></div> <div id="footer"> <div id="container"> <p>© <?php echo date('Y'); ?> Whatcouldicook</p> <ul> <li><a href="/about">About Us</a> </li> <li><a href="/contact">Contact</a> </li> <li><a href="/sitemap">Sitemap</a> </li> <li><a href="/search">Search</a> </li> <li><a href="/help">Help</a> </li> <li><a href="/jobs">Jobs</a> </li> <li><a href="/terms">Terms</a> </li> <li><a href="/privacy">Privacy</a></li> </ul> </div> </div> </div> </body> </html> <?php mysql_free_result($dsRecipes); ?> Link to comment https://forums.phpfreaks.com/topic/160131-using-a-dreamweaver-dataset-and-pagination-not-easy/ Share on other sites More sharing options...
bluedaniel Posted May 29, 2009 Author Share Posted May 29, 2009 no one? ive always had a lot of help from these forums, come on!! Link to comment https://forums.phpfreaks.com/topic/160131-using-a-dreamweaver-dataset-and-pagination-not-easy/#findComment-845190 Share on other sites More sharing options...
Ken2k7 Posted May 29, 2009 Share Posted May 29, 2009 If you want someone to write or re-work your code, then post in the Freelance forum. Link to comment https://forums.phpfreaks.com/topic/160131-using-a-dreamweaver-dataset-and-pagination-not-easy/#findComment-845196 Share on other sites More sharing options...
bluedaniel Posted May 29, 2009 Author Share Posted May 29, 2009 I dont want someone to completely re-write my code, although perhaps thats whats needed. I was thinking that the dreamweaver generated code could be slight modified to work with that script. Link to comment https://forums.phpfreaks.com/topic/160131-using-a-dreamweaver-dataset-and-pagination-not-easy/#findComment-845199 Share on other sites More sharing options...
bluedaniel Posted May 30, 2009 Author Share Posted May 30, 2009 Sorry people Ive ballsed this up a bit, Ive got my pagination working now to a point so close it hurts! http://www.whatcouldicook.com/allRecipes.php is the link that shows my trouble. The trouble is that Dreamweaver starts the recordset at page=0 which is a big problem, I cant for the life of me work out how to tell dreamweaver to start the page=1 instead. Ive changed the variables i dont know how many times but cant do it. Heres the code again <?php require_once('wordpress/wp-config.php'); require_once('wordpress/wp-includes/wp-db.php'); require_once('wordpress/wp-includes/pluggable.php'); require('includes/connection.php'); require('includes/pagination.php'); require('_drawratingmenu.php');?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $currentPage = $_SERVER["PHP_SELF"]; $maxRows_dsRecipes = 10; $pageNum_dsRecipes = 0; if (isset($_GET['pageNum_dsRecipes'])) { $pageNum_dsRecipes = $_GET['pageNum_dsRecipes']; } $startRow_dsRecipes = $pageNum_dsRecipes * $maxRows_dsRecipes; mysql_select_db($database_dsRecipes, $dsRecipes); $query_dsRecipes = "SELECT Title, SmallDesc, id, picturesmall FROM recipes ORDER BY Created_at DESC"; $query_limit_dsRecipes = sprintf("%s LIMIT %d, %d", $query_dsRecipes, $startRow_dsRecipes, $maxRows_dsRecipes); $dsRecipes = mysql_query($query_limit_dsRecipes, $dsRecipes) or die(mysql_error()); $row_dsRecipes = mysql_fetch_assoc($dsRecipes); if (isset($_GET['totalRows_dsRecipes'])) { $totalRows_dsRecipes = $_GET['totalRows_dsRecipes']; } else { $all_dsRecipes = mysql_query($query_dsRecipes); $totalRows_dsRecipes = mysql_num_rows($all_dsRecipes); } $totalPages_dsRecipes = ceil($totalRows_dsRecipes/$maxRows_dsRecipes); $queryString_dsRecipes = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_dsRecipes") == false && stristr($param, "totalRows_dsRecipes") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_dsRecipes = "&" . htmlentities(implode("&", $newParams)); } } $queryString_dsRecipes = sprintf("&totalRows_dsRecipes=%d%s", $totalRows_dsRecipes, $queryString_dsRecipes); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>What Can I Cook - Viewing all Recipes</title> <link href="/_css/base.css" rel="stylesheet" type="text/css" /> <link href="/_css/recipelistings.css" rel="stylesheet" type="text/css" /> <link href="/includes/pagination.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" language="javascript" src="js/behavior.js"></script> <script type="text/javascript" language="javascript" src="js/rating.js"></script> <link rel="SHORTCUT ICON" href="_images/favicon.ico" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="logoImage"></div> <div id="member"> <?php if (!is_user_logged_in()) echo "<p><a href='http://www.whatcouldicook.com/wordpress/wp-login.php?redirect_to=http://www.whatcouldicook.com/share.php'>Log in</a> / <a href='/wordpress/wp-login.php?action=register'>Sign up</a></p>"; else echo "<p>Welcome <a href='/share.php'>" . wp_get_current_user()->user_nicename . "</a> | <a href='" . wp_logout_url() . "'>Logout</a></p>" ?> </div> <form method="get" id="searchform" action="/searchresults.php"> <fieldset> <label for="s" class="hide">Quick Search:</label> <input type="text" name="s" id="s" onfocus="if (this.value == 'E.g. Lemon Cheesecake') {this.value = '';}" onblur="if (this.value == '') {this.value = 'E.g. Lemon Cheesecake';}" value="E.g. Lemon Cheesecake"/> <button type="submit" id="searchsubmit" value="Search">Go</button> </fieldset> </form> <div id="advert"><img src="http://m1.2mdn.net/viewad/2019228/Voda_prepay_728x90.gif" alt="advert" width="468" height="60" /></div> <ul id="mainNav"> <li><a href="index.php">Home </a></li> <li class="selected"><a href="allRecipes.php" class="selected">Recipes </a></li> <li><a href="features.php">Features </a></li> <li><a href="/wordpress/index.php">Blogs </a></li> <li><a href="/forum">Forum </a></li> <li><a href="share.php">Share </a></li> <li><a href="shop.html">Shop </a></li> </ul> </div> <ul id="secondaryNav"> <li><a href="/allRecipes.php">All Recipes </a></li> <li><a href="#">Celeb Chefs </a></li> <li><a href="/cuisines.php">Cuisines </a></li> <li><a href="#">Occasions </a></li> <li><a href="#">Special Diets </a></li> <li><a href="/vegetarian.php">Vegetarian </a></li> <li><a href="#">Cheap Eats </a></li> </ul> <div id="content"> <div id="title"> <h2>There are <span class="num"><?php echo $totalRows_dsRecipes ?> </span> recipes in total, you are browsing recipes <span class="num"><?php echo ($startRow_dsRecipes + 1) ?> to <?php echo min($startRow_dsRecipes + $maxRows_dsRecipes, $totalRows_dsRecipes) ?></span></h2> </div> <div class="love"> <?php echo getPaginationString($pageNum_dsRecipes, $totalRows_dsRecipes, $maxRows_dsRecipes, $adjacents, '/allRecipes.php', '?pageNum_dsRecipes='); ?> </div> <div id="searchfilter"> <h1>Recipe Index</h1> <form name="filter" method="post" action="/allRecipes.php"> <h2>Course</h2> <p><label><input name="checkbox" type="checkbox" id="checkbox1" value="1"/></label> Breakfast</p> <p><label><input name="checkbox" type="checkbox" id="checkbox2" value="2" /></label> Lunch</p> <p><label><input name="checkbox" type="checkbox" id="checkbox3" value="3" /></label> Dinner</p> <p><label><input name="dessert" type="checkbox" id="checkbox4" value="4" /></label> Dessert</p> <p><label><input name="checkbox2" type="checkbox" id="checkbox5" value="5" /></label> Snack</p> <h2>Time to Cook</h2> <p><label><input type="checkbox" name="checkbox3" id="checkbox6" /></label> Under 10 mins</p> <p><label><input type="checkbox" name="checkbox3" id="checkbox7" /></label> 10 - 30 mins</p> <p><label><input type="checkbox" name="checkbox3" id="checkbox8" /></label> 30 mins - 1 Hour</p> <p><label><input type="checkbox" name="dessert2" id="checkbox9" /></label> Between 1 - 2 Hours</p> <p><label><input type="checkbox" name="checkbox3" id="checkbox10" /></label> Over 2 hours</p> <h2>Special Considerations</h2> <p><label><input type="checkbox" id="checkbox11" value="1"/> </label> Vegetarian</p> <p><label><input type="checkbox" name="checkbox5" id="checkbox12" /></label> Vegan</p> <p><label><input type="checkbox" name="checkbox5" id="checkbox13" /></label> Cheap</p> <p><label><input type="checkbox" name="dessert3" id="checkbox14" /></label> Low-fat</p> <p><label><input type="checkbox" name="checkbox5" id="checkbox15" /></label> Low in salt</p> <h2>Author</h2> <p><label><input type="checkbox" name="checkbox4" id="checkbox16" /></label> User uploads</p> <p><label><input type="checkbox" name="checkbox6" id="checkbox17" /></label> Celebrity chef uploads</p><br/> </form> </div> <?php do { ?> <div class="method"> <h2><?php echo htmlentities($row_dsRecipes['Title']); ?></h2> <?php $recipeID = $row_dsRecipes['id']; echo rating_bar("$recipeID",'5', 'static'); ?> <p><a href="/recipe/<?php echo $row_dsRecipes['id']; ?>"><img src="<?php echo $row_dsRecipes['picturesmall']; ?>" name="recipeimg" class="recipeimg" alt="<?php echo htmlentities($row_dsRecipes['Title']); ?>" /></a></p> <p><?php echo htmlentities($row_dsRecipes['SmallDesc']); ?></p><br /> <p><a href="/recipe/<?php echo $row_dsRecipes['id']; ?>" class="link">Click here to view</a></p> </div> <?php } while ($row_dsRecipes = mysql_fetch_assoc($dsRecipes)); ?> <br /> </div> <div class="love"> </div> <div id="clear"></div> <div id="footer"> <div id="container"> <p>© 2009 WhatCanICook</p> <ul> <li><a href="/about">About Us</a> </li> <li><a href="/contact">Contact</a> </li> <li><a href="/sitemap">Sitemap</a> </li> <li><a href="/search">Search</a> </li> <li><a href="/help">Help</a> </li> <li><a href="/jobs">Jobs</a> </li> <li><a href="/terms">Terms</a> </li> <li><a href="/privacy">Privacy</a></li> </ul> </div> </div> </div> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-7843274-2"); pageTracker._trackPageview(); } catch(err) {}</script> </body> </html> <?php mysql_free_result($dsRecipes); ?> Thanks again Link to comment https://forums.phpfreaks.com/topic/160131-using-a-dreamweaver-dataset-and-pagination-not-easy/#findComment-845410 Share on other sites More sharing options...
bluedaniel Posted June 1, 2009 Author Share Posted June 1, 2009 anyone? Link to comment https://forums.phpfreaks.com/topic/160131-using-a-dreamweaver-dataset-and-pagination-not-easy/#findComment-846758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.