Re: [PHP] navigatie doesn't work in this script

2002-09-29 Thread Tom Rogers

Hi,

Monday, September 30, 2002, 5:20:48 AM, you wrote:
d> I made a MySQL database with a dictionary in it. Above there is a form in
d> wich you can specify some parameters. The problem is that the navigation
d> doesn't work well. I always get the first 5 results. Can somebody help me
d> out? There are about 56 records in the database.

d> The (not quite) working thing is on:
d> http://www.oostendseverhalen.be/test_met_navigatie3.php

d> 
d> 
d> Untitled Document
d> 
d> 

d> 

d>  /* hieronder volgt het formulier */
d> echo '
d> 
d>   
d>  
d>  cellpadding="2" summary="interactief woordenboek Oostends nederlands, Engels
en Frans.">>
d>   
d>   Ostensche
d> encyclopedie 
d>   
d>   >
d> >
d>   
d>   >
d>   Oostends-Drooghenbroodt
d>   
d>   
d>   
d>   Oostends-desnerck
d>   
d>  >
d> 
d> 
d> Nederlands
d> 
d> 
d> 
d> Frans
d> 
d> 
d>   
d>   
d>   Engels
d>   
d>   
d>   
d>   Verklaring
d>   
d> >Hulp
d> bij het zoeken
d>   
d>   >
d> >
d>  size="50" maxlength="40">
d> 
d>  
d>   
d>   
d>   
d> 
d>   

d>   
d> ';


d> if ($taalkeuze === NULL)
d> {
d> $taalkeuze = "woord_ost";
d> }


d> $van = 0;
d> $tot = 5;


d> mysql_connect("**.**.**.**", "**", "") or die (mysql_error());

d> $Query_beperkte_records = "SELECT woordenboek.* FROM woordenboek WHERE "
d> .$taalkeuze. " LIKE '%" .$zoekwoord. "%' ORDER BY woordenboek.woord_ost ASC
d> LIMIT ".$van.",".$tot;
d> $Query_alle_records = "SELECT woordenboek.* FROM woordenboek WHERE "
d> .$taalkeuze. " LIKE '%" .$zoekwoord. "%'";
d> $result = mysql("oostends",$Query_beperkte_records) or die(mysql_error());
d> $query = mysql("oostends",$Query_alle_records) or die(mysql_error());
d> $num3 = mysql_num_rows($query);
d> $num2 = $num3 / $tot;.
d> $num = ceil($num2);.

...snip
Here is a class that will create a google like pagination of results

count = $count;
$this->show = $show;
$this->maxpages = $max;
($this->count % $this->show == 0)? $this->pages = 
intval($this->count/$this->show) :$this->pages = intval($this->count/$this->show) +1;
if(!empty($_GET['search_page'])){
$this->page = $_GET['search_page'];
$this->start = $this->show * $this->page - $this->show;
}
}
function get_limit(){
$limit = '';
if($this->count > $this->show) $limit = 'LIMIT 
'.$this->start.','.$this->show;
return $limit;
}
function make_head_string($pre){
$r = $pre.' ';
$end = $this->start + $this->show;
if($end > $this->count) $end = $this->count;
$r .= ($this->start +1).' - '.$end.' of '.$this->count;
return $r;
}
function make_page_string($words,$pre='Result Page:'){
$r = $pre.' ';
if($this->page > 1){
$y = $this->page - 1;
$r .= 'Previous ';
}
$end = $this->page + $this->maxpages-1;
if($end > $this->pages) $end = $this->pages;
$x = $this->page - $this->maxpages;
$anchor = $this->pages - (2*$this->maxpages) +1;
if($anchor < 1) $anchor = 1;
if($x < 1) $x = 1;
if($x > $anchor) $x = $anchor;
while($x <= $end){
if($x == $this->page){
$r .= ''.$x.' ';
}
else{
$r.= ''.$x.' ';
}
$x++;
}
if($this->page < $this->pages){
$y = $this->page + 1;
$r .= 'Next ';
}
return $r;
}
}

//Usage

mysql_connect("**.**.**.**", "**", "") or die (mysql_error());

$Query_alle_records = "SELECT COUNT(*) AS cnt FROM woordenboek WHERE ".$taalkeuze. " 
LIKE '%" .$zoekwoord. "%'";
$query = mysql("oostends",$Query_alle_records) or die(mysql_error());
$row = mysql_fetch_array($result);
$count = $row['cnt'];
if($count > 0){
$page = new page_class($count,5,10); //total number of results,number of 
results to show,max number of pages on a sliding scale (ends up as 2x this number..ie 
20)
$limit = $page->get_limit();
$Query_beperkt

Re: [PHP] navigatie doesn't work in this script

2002-09-29 Thread danny

John,

Ik took this script from a script-library. The problem (i think) is that the
counter $tot isn't going up. It remains 5
ex:
http://www.oostendseverhalen.be/test_met_navigatie3.php?page=8&van=35&tot=5

John W. Holmes <[EMAIL PROTECTED]> schreef in berichtnieuws
001a01c267f3$90b8a8d0$[EMAIL PROTECTED]
> Search the archives for "previous next links" and you'll see a ton of
> ways to do this. You are setting the variables to 0 and 5 and then
> issuing the query. You have to put some logic in there to only set it to
> those values if it's the first time this page is called. If a $tot or
> $van value is passed in the URL, then you should use that.
>
> ---John Holmes...
>
> > -Original Message-
> > From: danny [mailto:[EMAIL PROTECTED]]
> > Sent: Sunday, September 29, 2002 3:56 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [PHP] navigatie doesn't work in this script
> >
> > In production this database will be verry big (about 1 records)
> and
> > for
> > almost every record a MP3 or picture. So i want to show only 5 records
> at
> > a
> > time. Therefore i tried to create a navigation system. And it isn't
> > working
> > properly now. (It doesn't go up), i always get the same five records.
> the
> > variables $van and $tot have to be the limits ("van" = from and "tot"
> > means
> > to)
> >
> > John W. Holmes <[EMAIL PROTECTED]> schreef in berichtnieuws
> > 001401c267ee$e6a510d0$[EMAIL PROTECTED]
> > > You have LIMIT 0,5 in your query...what do you expect to happen?
> You're
> > > only going to get five rows with that in there.
> > >
> > > ---John Holmes...
> > >
> > > > -Original Message-
> > > > From: danny [mailto:[EMAIL PROTECTED]]
> > > > Sent: Sunday, September 29, 2002 3:21 PM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: [PHP] navigatie doesn't work in this script
> > > >
> > > > I made a MySQL database with a dictionary in it. Above there is a
> form
> > > in
> > > > wich you can specify some parameters. The problem is that the
> > > navigation
> > > > doesn't work well. I always get the first 5 results. Can somebody
> help
> > > me
> > > > out? There are about 56 records in the database.
> > > >
> > > > The (not quite) working thing is on:
> > > > http://www.oostendseverhalen.be/test_met_navigatie3.php
> > > >
> > > > 
> > > > 
> > > > Untitled Document
> > > > 
> > > > 
> > > >
> > > > 
> > > >
> > > >  > > >
> > > > /* hieronder volgt het formulier */
> > > > echo '
> > > > 
> > > >   
> > > >  
> > > >  > > > cellpadding="2" summary="interactief woordenboek Oostends
> nederlands,
> > > > Engels
> > > > en Frans.">
> > > >   
> > > >   Ostensche
> > > > encyclopedie 
> > > >   
> > > >> > > bgcolor="#CC">
> > > >  > > > valign="middle">
> > > >   
> > > >value="woord_ost"
> > > > checked>
> > > >   Oostends-Drooghenbroodt
> > > >   
> > > >   
> > > >value="woord_des">
> > > >   Oostends-desnerck
> > > >   
> > > >   > > size="2"
> > > > face="Tahoma">
> > > > 
> > > >  value="woord_nl">
> > > > Nederlands
> > > > 
> > > > 
> > > >  value="woord_fr">
> > > > Frans
> > > > 
> > > >  face="Tahoma">
> > > >   
> > > >value="woord_eng">
> > > >   Engels
> > > >   
> > > >   
> > > >value="verklaring">
> > > >   Verklaring
> > > >   
> > > >  > 

RE: [PHP] navigatie doesn't work in this script

2002-09-29 Thread John W. Holmes

Search the archives for "previous next links" and you'll see a ton of
ways to do this. You are setting the variables to 0 and 5 and then
issuing the query. You have to put some logic in there to only set it to
those values if it's the first time this page is called. If a $tot or
$van value is passed in the URL, then you should use that. 

---John Holmes...

> -Original Message-
> From: danny [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 29, 2002 3:56 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] navigatie doesn't work in this script
> 
> In production this database will be verry big (about 1 records)
and
> for
> almost every record a MP3 or picture. So i want to show only 5 records
at
> a
> time. Therefore i tried to create a navigation system. And it isn't
> working
> properly now. (It doesn't go up), i always get the same five records.
the
> variables $van and $tot have to be the limits ("van" = from and "tot"
> means
> to)
> 
> John W. Holmes <[EMAIL PROTECTED]> schreef in berichtnieuws
> 001401c267ee$e6a510d0$[EMAIL PROTECTED]
> > You have LIMIT 0,5 in your query...what do you expect to happen?
You're
> > only going to get five rows with that in there.
> >
> > ---John Holmes...
> >
> > > -Original Message-
> > > From: danny [mailto:[EMAIL PROTECTED]]
> > > Sent: Sunday, September 29, 2002 3:21 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] navigatie doesn't work in this script
> > >
> > > I made a MySQL database with a dictionary in it. Above there is a
form
> > in
> > > wich you can specify some parameters. The problem is that the
> > navigation
> > > doesn't work well. I always get the first 5 results. Can somebody
help
> > me
> > > out? There are about 56 records in the database.
> > >
> > > The (not quite) working thing is on:
> > > http://www.oostendseverhalen.be/test_met_navigatie3.php
> > >
> > > 
> > > 
> > > Untitled Document
> > > 
> > > 
> > >
> > > 
> > >
> > >  > >
> > > /* hieronder volgt het formulier */
> > > echo '
> > > 
> > >   
> > >  
> > >  > > cellpadding="2" summary="interactief woordenboek Oostends
nederlands,
> > > Engels
> > > en Frans.">
> > >   
> > >   Ostensche
> > > encyclopedie 
> > >   
> > >> > bgcolor="#CC">
> > >  > > valign="middle">
> > >   
> > >> > checked>
> > >   Oostends-Drooghenbroodt
> > >   
> > >   
> > >   
> > >   Oostends-desnerck
> > >   
> > >   > size="2"
> > > face="Tahoma">
> > > 
> > > 
> > > Nederlands
> > > 
> > > 
> > > 
> > > Frans
> > > 
> > > 
> > >   
> > >   
> > >   Engels
> > >   
> > >   
> > >   
> > >   Verklaring
> > >   
> > >  > > face="Tahoma">Hulp
> > > bij het zoeken
> > >   
> > >> > bgcolor="#FF">
> > >  > > bgcolor="#CC">
> > >  > > value=""
> > > size="50" maxlength="40">
> > > 
> > >  
> > >   
> > >   
> > >   
> > > 
> > >   
> > >
> > >   
> > > ';
> > >
> > >
> > > if ($taalkeuze === NULL)
> > > {
> > > $taalkeuze = "woord_ost";
> > > }
> > >
> > >
> > > $van = 0;
> > > $tot = 5;
> > >
> > >
> > > mysql_connect("**.**.**.**", "**", "") or die
> > (mysql_error());
> > >
> > > $Query_beperkte_records = "SELECT woordenboek.

Re: [PHP] navigatie doesn't work in this script

2002-09-29 Thread danny

In production this database will be verry big (about 1 records) and for
almost every record a MP3 or picture. So i want to show only 5 records at a
time. Therefore i tried to create a navigation system. And it isn't working
properly now. (It doesn't go up), i always get the same five records. the
variables $van and $tot have to be the limits ("van" = from and "tot" means
to)

John W. Holmes <[EMAIL PROTECTED]> schreef in berichtnieuws
001401c267ee$e6a510d0$[EMAIL PROTECTED]
> You have LIMIT 0,5 in your query...what do you expect to happen? You're
> only going to get five rows with that in there.
>
> ---John Holmes...
>
> > -Original Message-
> > From: danny [mailto:[EMAIL PROTECTED]]
> > Sent: Sunday, September 29, 2002 3:21 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] navigatie doesn't work in this script
> >
> > I made a MySQL database with a dictionary in it. Above there is a form
> in
> > wich you can specify some parameters. The problem is that the
> navigation
> > doesn't work well. I always get the first 5 results. Can somebody help
> me
> > out? There are about 56 records in the database.
> >
> > The (not quite) working thing is on:
> > http://www.oostendseverhalen.be/test_met_navigatie3.php
> >
> > 
> > 
> > Untitled Document
> > 
> > 
> >
> > 
> >
> >  >
> > /* hieronder volgt het formulier */
> > echo '
> > 
> >   
> >  
> >  > cellpadding="2" summary="interactief woordenboek Oostends nederlands,
> > Engels
> > en Frans.">
> >   
> >   Ostensche
> > encyclopedie 
> >   
> >> bgcolor="#CC">
> >  > valign="middle">
> >   
> >> checked>
> >   Oostends-Drooghenbroodt
> >   
> >   
> >   
> >   Oostends-desnerck
> >   
> >   size="2"
> > face="Tahoma">
> > 
> > 
> > Nederlands
> > 
> > 
> > 
> > Frans
> > 
> > 
> >   
> >   
> >   Engels
> >   
> >   
> >   
> >   Verklaring
> >   
> >  > face="Tahoma">Hulp
> > bij het zoeken
> >   
> >> bgcolor="#FF">
> >  > bgcolor="#CC">
> >  > value=""
> > size="50" maxlength="40">
> > 
> >  
> >   
> >   
> >   
> > 
> >   
> >
> >   
> > ';
> >
> >
> > if ($taalkeuze === NULL)
> > {
> > $taalkeuze = "woord_ost";
> > }
> >
> >
> > $van = 0;
> > $tot = 5;
> >
> >
> > mysql_connect("**.**.**.**", "**", "") or die
> (mysql_error());
> >
> > $Query_beperkte_records = "SELECT woordenboek.* FROM woordenboek WHERE
> "
> > .$taalkeuze. " LIKE '%" .$zoekwoord. "%' ORDER BY
> woordenboek.woord_ost
> > ASC
> > LIMIT ".$van.",".$tot;
> > $Query_alle_records = "SELECT woordenboek.* FROM woordenboek WHERE "
> > .$taalkeuze. " LIKE '%" .$zoekwoord. "%'";
> > $result = mysql("oostends",$Query_beperkte_records) or
> die(mysql_error());
> > $query = mysql("oostends",$Query_alle_records) or die(mysql_error());
> > $num3 = mysql_num_rows($query);
> > $num2 = $num3 / $tot;.
> > $num = ceil($num2);.
> >
> >
> > if ($num > 1)
> >  {
> >  for ($i = 1; $i <= $num; $i++)
> >
> >
> >   $van2 = ($i * $tot) - $tot;
> >   if ($i == $page)
> >$pages[$i] = " > color=\"#C0C0C0\">$i";.
> >   else
> >$pages[$i] = " > href=\"$php_self?page=$i&van=$van2&tot=$tot\">$i";
> > }
> >  $pages = implode(" | ", $pages);
> >  $vorige = ($page-1) ? " > href=\"$php_self?page=" . ($page - 1) . "&van=" . ($van - $tot) .
> > "&tot=$tot\">< Vorige" : "";
> >  $volgende = ($page-$num) ? " > href=\"$php_self?page=" . ($page + 1) . "&van=" . ($van + $tot) .
> > "&tot=$tot\">Volgende >" : "";
> >
> >  if ($vorige && $volgende)
> >   $navigation = "$vorige | $pages | $volgende";
> >  else
> >   $navigation = "$vorige | $pages | $volgende";
> >  }
> > print $navigation;
> >
> >
> > while ($gegevens=mysql_fetch_object($result))
> > {
> > echo
> > " summary=\"oostends
> > interactief woordenboek\">
> >   
> >  > align=\"left\"> > face=\"Tahoma\">".
> > $gegevens->woord_ost. "";
> >  if ($gegevens->geluid  != NULL)
> >   {
> >echo "geluid. "\"> > src=\"plaatjes/button_luister.gif\" width=\"21\" height=\"24\"
> > border=\"0\">";}
> >   else
> >  {
> >   echo "";
> >  }
> >
> >   echo "
> >   geluid. "\"> > src=\"plaatjes/button_statistiek.gif\" width=\"21\" height=\"24\"
> > border=\"0\">
> >  geluid. "\"> > src=\"plaatjes/button_stemmen.gif\" width=\"21\" height=\"24\"
> > border=\"0\">
> > 
> >  > align=\"left\"> > face=\"Tahoma\">Volgnr
> >  > color=\"#009966\">"
> >  .$gegevens->woord_des.  " (ost_desn) ,
> > "
> >  .$gegevens->woord_nl.  " (nl) ,   > size=\"2\">"
> > .$gegevens->woord_f

RE: [PHP] navigatie doesn't work in this script

2002-09-29 Thread John W. Holmes

You have LIMIT 0,5 in your query...what do you expect to happen? You're
only going to get five rows with that in there.

---John Holmes...

> -Original Message-
> From: danny [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 29, 2002 3:21 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] navigatie doesn't work in this script
> 
> I made a MySQL database with a dictionary in it. Above there is a form
in
> wich you can specify some parameters. The problem is that the
navigation
> doesn't work well. I always get the first 5 results. Can somebody help
me
> out? There are about 56 records in the database.
> 
> The (not quite) working thing is on:
> http://www.oostendseverhalen.be/test_met_navigatie3.php
> 
> 
> 
> Untitled Document
> 
> 
> 
> 
> 
>  
> /* hieronder volgt het formulier */
> echo '
> 
>   
>  
>  cellpadding="2" summary="interactief woordenboek Oostends nederlands,
> Engels
> en Frans.">
>   
>   Ostensche
> encyclopedie 
>   
>bgcolor="#CC">
>  valign="middle">
>   
>checked>
>   Oostends-Drooghenbroodt
>   
>   
>   
>   Oostends-desnerck
>   
>   face="Tahoma">
> 
> 
> Nederlands
> 
> 
> 
> Frans
> 
> 
>   
>   
>   Engels
>   
>   
>   
>   Verklaring
>   
>  face="Tahoma">Hulp
> bij het zoeken
>   
>bgcolor="#FF">
>  bgcolor="#CC">
>  value=""
> size="50" maxlength="40">
> 
>  
>   
>   
>   
> 
>   
> 
>   
> ';
> 
> 
> if ($taalkeuze === NULL)
> {
> $taalkeuze = "woord_ost";
> }
> 
> 
> $van = 0;
> $tot = 5;
> 
> 
> mysql_connect("**.**.**.**", "**", "") or die
(mysql_error());
> 
> $Query_beperkte_records = "SELECT woordenboek.* FROM woordenboek WHERE
"
> .$taalkeuze. " LIKE '%" .$zoekwoord. "%' ORDER BY
woordenboek.woord_ost
> ASC
> LIMIT ".$van.",".$tot;
> $Query_alle_records = "SELECT woordenboek.* FROM woordenboek WHERE "
> .$taalkeuze. " LIKE '%" .$zoekwoord. "%'";
> $result = mysql("oostends",$Query_beperkte_records) or
die(mysql_error());
> $query = mysql("oostends",$Query_alle_records) or die(mysql_error());
> $num3 = mysql_num_rows($query);
> $num2 = $num3 / $tot;.
> $num = ceil($num2);.
> 
> 
> if ($num > 1)
>  {
>  for ($i = 1; $i <= $num; $i++)
> 
> 
>   $van2 = ($i * $tot) - $tot;
>   if ($i == $page)
>$pages[$i] = " color=\"#C0C0C0\">$i";.
>   else
>$pages[$i] = " href=\"$php_self?page=$i&van=$van2&tot=$tot\">$i";
> }
>  $pages = implode(" | ", $pages);
>  $vorige = ($page-1) ? " href=\"$php_self?page=" . ($page - 1) . "&van=" . ($van - $tot) .
> "&tot=$tot\">< Vorige" : "";
>  $volgende = ($page-$num) ? " href=\"$php_self?page=" . ($page + 1) . "&van=" . ($van + $tot) .
> "&tot=$tot\">Volgende >" : "";
> 
>  if ($vorige && $volgende)
>   $navigation = "$vorige | $pages | $volgende";
>  else
>   $navigation = "$vorige | $pages | $volgende";
>  }
> print $navigation;
> 
> 
> while ($gegevens=mysql_fetch_object($result))
> {
> echo
> " interactief woordenboek\">
>   
>  align=\"left\"> face=\"Tahoma\">".
> $gegevens->woord_ost. "";
>  if ($gegevens->geluid  != NULL)
>   {
>echo "geluid. "\"> src=\"plaatjes/button_luister.gif\" width=\"21\" height=\"24\"
> border=\"0\">";}
>   else
>  {
>   echo "";
>  }
> 
>   echo "
>   geluid. "\"> src=\"plaatjes/button_statistiek.gif\" width=\"21\" height=\"24\"
> border=\"0\">
>  geluid. "\"> src=\"plaatjes/button_stemmen.gif\" width=\"21\" height=\"24\"
> border=\"0\">
> 
>  align=\"left\"> face=\"Tahoma\">Volgnr
>  color=\"#009966\">"
>  .$gegevens->woord_des.  " (ost_desn) ,
> "
>  .$gegevens->woord_nl.  " (nl) ,   size=\"2\">"
> .$gegevens->woord_fr.  " (fr) ,size=\"2\">"
>  .$gegev
> ens->woord_eng.  " (eng) ,
>  size=\"2\">"
>  .$gegevens->verklaring."
>   
>   ";
> if ($gegevens->multimedia  != NULL)
>   {
>   echo " .$gegevens->multimedia. "\" width=\"170\" height=\"124\"
> border=\"1\">";
>   }
>  else
>   {
>   echo "";
>   }
> echo "  ";
> echo "";
> }
> print $navigation;
> 
> ?>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php