Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


 
 re-posting
Author:  (203.106.219.---)
Date:   02-24-04 22:22

Hi,
i just repost this topic after finding out there's no reply for it, thus i'm having the same problem.
Anybody that can help and/or give their opinion would be much appreciated.

foodstyling, i'm reposting your topic.

thanks.

---------------------------------------------------------------
I have a problem to get a pagination system to work:
I have 1 form with I select query named catID and a text search named ingredienten.
The answers for the queries are ok. The results for the first page are correct, but when I go to the second page I get no results at all. Anybody with a solution?

The code for the results page looks like this:

Foodstyling

<?php
if(!isset($_GET['page'])) {
$page = 1;
} else {

$page = $_GET['page'];
}
$max_results = 5;

$from =(($page * $max_results) - $max_results);

$catID = $_POST['catID'];
if (count($catID) > 0) {
// loop through the array
for ($i=0;$i<count($catID);$i++) {

}

}

$result= "SELECT catID, catName FROM categories WHERE catID = ('$catID') ORDER BY catID";
$result= mysql_query($result);
while ($row = mysql_fetch_array($result)) {
$catID = $row['catID'];
}

$param1=($_POST['ingredienten']);

$recept = $_POST['ingredienten'];
if (count($recept) > 0) {
// loop through the array
for ($i=0;$i<count($recept);$i++) {



}
}

if (!empty($_POST['ingredienten'])){


//use single quote when searching for text elements
//use "%" before AND after to allow search for elements that occur in
//the middle of the string

$result ="SELECT recept AS RECEPTEN FROM recepten WHERE ingredienten LIKE
'%$param1%' AND catID = ('$catID') ORDER BY recept LIMIT $from, $max_results";
$result = mysql_query($result);
while ($row = mysql_fetch_array($result)) {

$recept=$row['recept'];

// show table
echo "<p>\n";
show_table($result);
echo "</p>\n";
}
}
else{
echo "<h3><font color=#O42C89>U HEEFT GEEN INGREDIENT INGEVOERD</font></h3>";
}
if(mysql_num_rows($result) == 0)
{
echo"<h3><font color=#O42C89>SORRY, ER ZIJN GEEN RESULTATEN GEVONDEN.<br
PROBEER HET OPNIEUW IN EEN ANDERE CATEGORIE OF MET EEN ANDER INGREDIENT.</font></h3>";
}
$total_results = mysql_query("SELECT COUNT(recept) AS Num FROM recepten WHERE ingredienten LIKE
'%$param1%' AND catID = ('$catID')");
while($row = mysql_fetch_array($total_results));
$recept=$row['recept'];

echo "<p>Er zijn in het totaal<font color = #042C89> ",mysql_result($total_results,0, 0),"</font>
recepten welke beantwoorden aan uw zoekopdracht </p\n";



// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);


// Build Previous Link

if($page>1) {
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?ingredienten=%$param1%&catID=$catID&page=$prev\"><< Previous</a> ";
}

for($i=1; $i<= $total_pages; $i++){
if(($page) == $i) {
echo " $i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?ingredienten=%$param1%&catID=$catID&page=$i\"> $i</a> ";
}
}

// Build Next Link
if($page<$total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?ingredienten=%$param1%&catID=$catID&page=$next\"> Next >></a>";
}

 Re: re-posting
Author:  (203.106.219.---)
Date:   02-26-04 20:31

got it already..Not using this code though.

Go to Top  |  Go to Topic  |  Threaded View  |  Search 
  |  
New Topic
 Reply To This Message
 Your Name:
 Your Email:
 Subject:
Email replies to this thread, to the address above.
  

Provided By
Phorum