Jump to content


Photo

Pagination help


  • Please log in to reply
1 reply to this topic

#1 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 21 July 2006 - 12:30 PM

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:

<html>
<body>
<head>
<link href="resultcss.css" rel="stylesheet" type="text/css" />
</head>
<?php
include('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>

Here's the rest of the code I had to go after that...

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++;
}

http://www.DaveLinger.com
dave at linger dot com

#2 Oldiesmann

Oldiesmann
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationCincinnati, Ohio

Posted 21 July 2006 - 03:33 PM

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:

<html>
<head>
<link href="resultcss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include('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>

The rest of the code that you have after that should be fine.
The Oldiesmann
SMF Project Manager
SMF+Gallery2 - Beta3.1 now available




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users