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: undifined index
Author:  (---.54-136-217.adsl.skynet.be)
Date:   02-16-04 22:43

Thanks,
I nfact I am trying to make a previous/next page script, and cannot make it work. The code for is like this. It works till I got the first page of results, and doesn't pass the results to the next page. The message is: Er zijn geen ingredienten ingevoerd...
I tried to make the post easier, because it behaves the same with select as Num...
line.

if(!empty($_POST['catID']))
{
$catID = $_POST['catID'];
}
$param1=($_POST['ingredienten']);

$catID = $_POST['catID'];

if (!($limit)){
$limit = 5;} // Default results per-page.

if (!($page)){
$page = 0;} // Default page value.



$numresults = mysql_query_test("SELECT recept AS RECEPTEN FROM recepten WHERE ingredienten LIKE
'%" . $param1 . "%' AND catID = ('$catID') "); // the query.

$numrows = mysql_num_rows($numresults); // Number of rows returned from above query.



$pages = intval($numrows/$limit); // Number of results pages.

// $pages now contains int of pages, unless there is a remainder from division.

if ($numrows % $limit) {
$pages++;} // has remainder so add one page

$current = ($page/$limit) + 1; // Current page number.

if (($pages < 1) || ($pages == 0)) {
$total = 1;} // If $pages is less than one or equal to 0, total pages is 1.

else {
$total = $pages;} // Else total pages is $pages value.

$first = $page + 1; // The first result.

if (!((($page + $limit) / $limit) >= $pages) && $pages != 1) {
$last = $page + $limit;} //If not last results page, last result equals $page plus $limit.

else{
$last = $numrows;} // If last results page, last result equals total number of results.
?>


your sessionID is:














Aantal gevonden recepten - van

Pagina van

 

Recepten per pagina: 5 | 10 | 20 | 50





if (count($catID) > 0) {
// loop through the array
for ($i=0;$i
}

}

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



$recept = $_POST['ingredienten'];

if (count($recept) > 0) {
// loop through the array
for ($i=0;$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

$sql = mysql_query_test("SELECT recept AS RECEPTEN FROM recepten WHERE ingredienten LIKE
'%" . $param1 . "%' AND catID = ('$catID') ORDER BY recept limit $page, $limit ");

while ($row = mysql_fetch_array($sql)) {
$recept = $row['recept'];
echo $row['recept'] ."
";

// show table

echo "

\n";
show_table($sql);
echo "

\n";
}
}
else{
echo "

U HEEFT GEEN INGREDIENT INGEVOERD

";
}
if(mysql_num_rows($result) == 0)
{
echo"

SORRY, ER ZIJN GEEN RESULTATEN GEVONDEN. PROBEER HET OPNIEUW IN EEN ANDERE CATEGORIE OF MET EEN ANDER INGREDIENT.

";
}
$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 "

Er zijn in het totaal ",mysql_result($total_results,0, 0),"
recepten welke beantwoorden aan uw zoekopdracht
if ($page != 0) { // Don't show back link if current page is first page.
$back_page = $page - $limit;
echo("vorige   \n");}

for ($i=1; $i <= $pages; $i++) // loop through each page and give link to it.
{
$ppage = $limit * ($i - 1);
if ($ppage == $page){
echo("$i\n");} // If current page don't give link, just text.
else{
echo("$i \n");}
}

if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { // If last page don't give next link.
$next_page = $page + $limit;
echo("volgende");}
?>

 Topics Author  Date
 undifined index  new
foodstyling 02-14-04 13:55 
 Re: undifined index  new
bastien 02-16-04 17:56 
 Re: undifined index  new
foodstyling 02-16-04 22:43 
 Re: undifined index  new
mike... 02-22-04 07:11 
Go to Top  |  Go to Topic  |  Flat View  |  Search 
  |  
New Topic
 Reply To This Message
 Your Name:
 Your Email:
 Subject:
Email replies to this thread, to the address above.
  wrote: > > Thanks, > I nfact I am trying to make a previous/next page script, and > cannot make it work. The code for is like this. It works till > I got the first page of results, and doesn't pass the results > to the next page. The message is: Er zijn geen ingredienten > ingevoerd... > I tried to make the post easier, because it behaves the same > with select as Num... > line. > > if(!empty($_POST['catID'])) > { > $catID = $_POST['catID']; > } > $param1=($_POST['ingredienten']); > > $catID = $_POST['catID']; > > if (!($limit)){ > $limit = 5;} // Default results per-page. > > if (!($page)){ > $page = 0;} // Default page value. > > > > $numresults = mysql_query_test("SELECT recept AS RECEPTEN > FROM recepten WHERE ingredienten LIKE > '%" . $param1 . "%' AND catID = ('$catID') "); // the query. > > $numrows = mysql_num_rows($numresults); // Number of rows > returned from above query. > > > > $pages = intval($numrows/$limit); // Number of results pages. > > // $pages now contains int of pages, unless there is a > remainder from division. > > if ($numrows % $limit) { > $pages++;} // has remainder so add one page > > $current = ($page/$limit) + 1; // Current page number. > > if (($pages < 1) || ($pages == 0)) { > $total = 1;} // If $pages is less than one or equal to 0, > total pages is 1. > > else { > $total = $pages;} // Else total pages is $pages value. > > $first = $page + 1; // The first result. > > if (!((($page + $limit) / $limit) >= $pages) && $pages != 1) { > $last = $page + $limit;} //If not last results page, last > result equals $page plus $limit. > > else{ > $last = $numrows;} // If last results page, last result > equals total number of results. > ?> > > >

your sessionID is:
> >

> > > > > > > > > > >
> Aantal gevonden recepten - > van > > Pagina van >
>   >
> Recepten per pagina: href="results.php?ingredienten=$param1&catID=$catID&page=&limit=5">5 | 10 | 20 | 50 >
> > > > > if (count($catID) > 0) { > // loop through the array > for ($i=0;$i > } > > } > > $result= "SELECT catID, catName FROM categories WHERE catID = > ('$catID')"; > $result= mysql_query_test($result); > while ($row = mysql_fetch_array($result)) { > $catID = $row['catID']; > } > > > > $recept = $_POST['ingredienten']; > > if (count($recept) > 0) { > // loop through the array > for ($i=0;$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 > > $sql = mysql_query_test("SELECT recept AS RECEPTEN FROM > recepten WHERE ingredienten LIKE > '%" . $param1 . "%' AND catID = ('$catID') ORDER BY recept > limit $page, $limit "); > > while ($row = mysql_fetch_array($sql)) { > $recept = $row['recept']; > echo $row['recept'] ."
"; > > // show table > > echo "

\n"; > show_table($sql); > echo "

\n"; > } > } > else{ > echo "

U HEEFT GEEN INGREDIENT > INGEVOERD

"; > } > if(mysql_num_rows($result) == 0) > { > echo"

SORRY, ER ZIJN GEEN RESULTATEN > GEVONDEN.
PROBEER HET OPNIEUW IN EEN ANDERE CATEGORIE OF MET EEN ANDER > INGREDIENT.

"; > } > $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 "

Er zijn in het totaal > ",mysql_result($total_results,0, 0)," > recepten welke beantwoorden aan uw zoekopdracht > if ($page != 0) { // Don't show back link if current page is > first page. > $back_page = $page - $limit; > echo(" href=\"results.php?ingredienten=$param1&catId=$catID&page=$back_page&limit=$limit\">vorige   \n");} > > for ($i=1; $i <= $pages; $i++) // loop through each page and > give link to it. > { > $ppage = $limit * ($i - 1); > if ($ppage == $page){ > echo("$i\n");} // If current page don't give link, > just text. > else{ > echo(" href=\"results.php?ingredienten=$param1&catID=$catID&page=$ppage&limit=$limit\">$i \n");} > } > > if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { > // If last page don't give next link. > $next_page = $page + $limit; > echo(" href=\"results.php?ingredienten=$param1&catID=$catID&page=$next_page&limit=$limit\">volgende");} > ?> ">  


Provided By
Phorum