DaveLinger Posted July 21, 2006 Share Posted July 21, 2006 here's the code I've got so far... I had more but I cut it off because it wasn't working, but even this shows a blank page:[code]<html><body><head><link href="resultcss.css" rel="stylesheet" type="text/css" /></head><?phpinclude('config/file.php');if($_POST['platform'] == ''){ $platform = $_GET['platform'];$developer = $_GET['developer'];$publisher = $_GET['publisher'];$fletter = $_GET['fletter'];$sortby = $_GET['sort'];$perpage = $_GET['perpage'];$order = $_GET['order'];}else{$platform = $_POST['platform'];$developer = $_POST['developer'];$publisher = $_POST['publisher'];$fletter = $_POST['fletter'];$sortby = $_POST['sort'];$perpage = $_POST['perpage'];$order = $_POST['order'];}if (!$link = mysql_connect($sqlserver, $sqlusername, $sqlpassword)) { echo 'Could not connect to mysql'; exit;}if (!mysql_select_db($sqldatabase, $link)) { echo 'Could not select database'; exit;}//////////////////////////////////////////////////////////if($fletter == '%'){$resource1 = mysql_query('SELECT * FROM nuke_seccont WHERE secid LIKE '$platform' AND developer LIKE '$developer' AND publisher LIKE '$publisher' ORDER BY $sortby $order') or die(mysql_error());}ELSE{$resource1 = mysql_query('SELECT * FROM nuke_seccont WHERE secid LIKE '$platform' AND developer LIKE '$developer' AND publisher LIKE '$publisher' AND fletter=$fletter' ORDER BY $sortby $order') or die(mysql_error());}$total_results = mysql_result($resource1, 0, 0);$total_pages = ceil($total_results / $perpage);$current_page = (isset($_GET['page'])) ? $_GET['page'] : 1;$current_offset = ($current_page - 1) * $per_page;echo "total pages: $total_pages<br>current page: $current_page<br>current offset: $current_offset";}?></body></html>[/code]Here's the rest of the code I had to go after that...[code]if($fletter == '%'){$this_page_results = "SELECT * FROM nuke_seccont WHERE secid LIKE '$platform' AND developer LIKE '$developer' AND publisher LIKE '$publisher' ORDER BY $sortby $order LIMIT $current_offset, $perpage";}ELSE{$this_page_results = "SELECT * FROM nuke_seccont WHERE secid LIKE '$platform' AND developer LIKE '$developer' AND publisher LIKE '$publisher' AND fletter=$fletter' ORDER BY $sortby $order LIMIT $current_offset, $perpage";}$result = mysql_query($this_page_results) or die("Problem with the query: $query<br>" . mysql_error());mysql_close();$nextpage = $pagenumber + 1;echo "<p align=\"right\">Page $current_page of $total_pages <br><a href=\"gosearch.php?page=$nextpage&platform=$platform&developer=$developer&publisher=$publisher&fletter=$fletter&sortby=$sort&perpage=$perpage&order=$order\">Next Page</a></p>Search successful! $numberofresults results found.";$i=0;while ($i < $perpage) {$artid=mysql_result($result,$i,"artid");$secid=mysql_result($result,$i,"secid");$title=mysql_result($result,$i,"title");$counter=mysql_result($result,$i,"counter");$score6=mysql_result($result,$i,"score6");echo "<p>● <a href=\"review.php?artid=$artid\" title=\"$title's final score is $score6. It has $counter hits\" target=\"_parent\"><b>$title</b></a><p>";$i++;}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15248-pagination-help/ Share on other sites More sharing options...
Oldiesmann Posted July 21, 2006 Share Posted July 21, 2006 If you want to enclose variables in single quotes, then you either need to use double quotes for the query string or escape the single quotes. Also, <head> cannot come after <body>. Try this:[code]<html><head><link href="resultcss.css" rel="stylesheet" type="text/css" /></head><body><?phpinclude('config/file.php');if($_POST['platform'] == ''){ $platform = $_GET['platform'];$developer = $_GET['developer'];$publisher = $_GET['publisher'];$fletter = $_GET['fletter'];$sortby = $_GET['sort'];$perpage = $_GET['perpage'];$order = $_GET['order'];}else{$platform = $_POST['platform'];$developer = $_POST['developer'];$publisher = $_POST['publisher'];$fletter = $_POST['fletter'];$sortby = $_POST['sort'];$perpage = $_POST['perpage'];$order = $_POST['order'];}if (!$link = mysql_connect($sqlserver, $sqlusername, $sqlpassword)) { echo 'Could not connect to mysql'; exit;}if (!mysql_select_db($sqldatabase, $link)) { echo 'Could not select database'; exit;}//////////////////////////////////////////////////////////if($fletter == '%'){$resource1 = mysql_query("SELECT * FROM nuke_seccont WHERE secid LIKE '$platform' AND developer LIKE '$developer' AND publisher LIKE '$publisher' ORDER BY " . $sortby . " " . $order) or die(mysql_error());}ELSE{$resource1 = mysql_query("SELECT * FROM nuke_seccont WHERE secid LIKE '$platform' AND developer LIKE '$developer' AND publisher LIKE '$publisher' AND fletter='$fletter' ORDER BY " . $sortby . " " . $order) or die(mysql_error());}$total_results = mysql_result($resource1, 0, 0);$total_pages = ceil($total_results / $perpage);$current_page = (isset($_GET['page'])) ? $_GET['page'] : 1;$current_offset = ($current_page - 1) * $per_page;echo "total pages: $total_pages<br>current page: $current_page<br>current offset: $current_offset";}?></body></html>[/code]The rest of the code that you have after that should be fine. Quote Link to comment https://forums.phpfreaks.com/topic/15248-pagination-help/#findComment-61689 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.