Re: [PHP] My first post

2002-12-04 Thread Victor Espina
Thank you a lot! That is exactly what i was looking for.

--
==
Victor J. Espina S.
Gerente de Desarrollo / Software Development Manager
Software de Venezuela, S.A.
Caracas, Venezuela

Email: [EMAIL PROTECTED]
Personal site: http://victorespina.coolfreepages.com
MSN: [EMAIL PROTECTED]
==
(Elimine 'nospam' en las direcciones email)
(Remove 'nospam' in email and MSN address)
==
Tom Rogers [EMAIL PROTECTED] escribió en el mensaje
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi,

 Tuesday, December 3, 2002, 7:37:20 AM, you wrote:
 VE Hi.

 VE I'm new in PHP. Could you point me where can i download a sample
script
 VE about how can i paginate some results?

 VE TIA
 Here is a class that will create a google like pagination of results  if
that is
 what you are after :)

 ?
 class page_class {
 var $count = 0; //total pages
 var $start = 0; //starting record
 var $pages = 0; //number of pages available
 var $page = 1;  //current page
 var $maxpages;  //shows up to 2 * this number and makes a
sliding scale
 var $show;  //number of results per page
 function page_class($count=0,$show=5,$max=9){
 $this-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 .= 'a
href='.$_SERVER['PHP_SELF'].'?search_page='.$y.$words.'Previous/anbsp;
';
 }
 $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 .= 'span
class=s'.$x.'/spannbsp;';
 }
 else{
 $r.= 'a
href='.$_SERVER['PHP_SELF'].'?search_page='.$x.$words.''.$x.'/anbsp;';
 }
 $x++;
 }
 if($this-page  $this-pages){
 $y = $this-page + 1;
 $r .= 'a
href='.$_SERVER['PHP_SELF'].'?search_page='.$y.$words.'Next/anbsp;';
 }
 return $r;
 }
 }

 //Usage

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

 $Query = SELECT COUNT(*) AS cnt FROM tabletosearch WHERE fieldtosearch
LIKE '% .$searchword. %';
 $query = mysql_query($Query) or die(mysql_error());
 $row = mysql_fetch_array($result);
 $count = $row['cnt'];
 if($count  0){
   //start class 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)
 $page = new page_class($count,5,10);
 $limit = $page-get_limit();
 $Query2= SELECT * FROM tabletosearch WHERE fieldtosearch LIKE '%
.$searchword. %' ORDER BY  whatever ASC .$limit;
 $result = mysql_query($Query2) or die(mysql_error());
 $hstring = $page-make_head_string('Results');
 $pstring =
$page-make_page_string(amp;searchword=.$searchword.amp;whatever=.$wha
tever);//add the other variables to pass to next page in a similar fashion
 echo tabletrtd.$hstring./td/tr;
 while($row = mysql_fetch_array($result)){
echo trtd.$show_data_here./td/tr;
 }
 echo trtd.$pstring./td/tr/table;
 }
 ?
 Note: the search variables on subsequent pages will be passed by GET
method








 --
 regards,
 Tom




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

Re: [PHP] My first post

2002-12-04 Thread Victor Espina
Thank you. I'm a VFP programmer (since 1989!) and have some time looking for
a way to move to the Web world. I heard about PHP about 1 year ago, but was
just a few months ago when i finally download it and started to look what is
all about.  And what i found was an incredible powerfull language, with a
great OOP implementation, an elegant sintax, a lot of native functions and
the mos important: REALLY FAST!!

So, you can bet you will see me here a lot, bothering you with stupid
questions! :-)

--
==
Victor J. Espina S.
Gerente de Desarrollo / Software Development Manager
Software de Venezuela, S.A.
Caracas, Venezuela

Email: [EMAIL PROTECTED]
Personal site: http://victorespina.coolfreepages.com
MSN: [EMAIL PROTECTED]
==
(Elimine 'nospam' en las direcciones email)
(Remove 'nospam' in email and MSN address)
==
Dl Neil [EMAIL PROTECTED] escribió en el mensaje
0f6601c29aeb$2d3deba0$c900a8c0@jrbrown">news:0f6601c29aeb$2d3deba0$c900a8c0@jrbrown...
 Hi Victor,
 Welcome to the wonderful world of PHP!

  I'm new in PHP. Could you point me where can i download a sample script
  about how can i paginate some results?


 PHP essentially exists to output HTML. You cannot paginate in HTML
(although
 there is some fancy CSS that could be employed).

 Sorry,
 =dn




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




Re: [PHP] My first post

2002-12-03 Thread DL Neil
Hi Victor,
Welcome to the wonderful world of PHP!

 I'm new in PHP. Could you point me where can i download a sample script
 about how can i paginate some results?


PHP essentially exists to output HTML. You cannot paginate in HTML (although
there is some fancy CSS that could be employed).

Sorry,
=dn


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




Re: [PHP] My first post

2002-12-03 Thread Tom Rogers
Hi,

Tuesday, December 3, 2002, 7:37:20 AM, you wrote:
VE Hi.

VE I'm new in PHP. Could you point me where can i download a sample script
VE about how can i paginate some results?

VE TIA
Here is a class that will create a google like pagination of results  if that is
what you are after :)

?
class page_class {
var $count = 0; //total pages
var $start = 0; //starting record
var $pages = 0; //number of pages available
var $page = 1;  //current page
var $maxpages;  //shows up to 2 * this number and makes a sliding scale
var $show;  //number of results per page
function page_class($count=0,$show=5,$max=9){
$this-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 .= 'a 
href='.$_SERVER['PHP_SELF'].'?search_page='.$y.$words.'Previous/anbsp;';
}
$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 .= 'span class=s'.$x.'/spannbsp;';
}
else{
$r.= 'a 
href='.$_SERVER['PHP_SELF'].'?search_page='.$x.$words.''.$x.'/anbsp;';
}
$x++;
}
if($this-page  $this-pages){
$y = $this-page + 1;
$r .= 'a 
href='.$_SERVER['PHP_SELF'].'?search_page='.$y.$words.'Next/anbsp;';
}
return $r;
}
}

//Usage

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

$Query = SELECT COUNT(*) AS cnt FROM tabletosearch WHERE fieldtosearch LIKE '% 
.$searchword. %';
$query = mysql_query($Query) or die(mysql_error());
$row = mysql_fetch_array($result);
$count = $row['cnt'];
if($count  0){
  //start class 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)
$page = new page_class($count,5,10); 
$limit = $page-get_limit();
$Query2= SELECT * FROM tabletosearch WHERE fieldtosearch LIKE '% 
.$searchword. %' ORDER BY  whatever ASC .$limit;
$result = mysql_query($Query2) or die(mysql_error());
$hstring = $page-make_head_string('Results');
$pstring = 
$page-make_page_string(amp;searchword=.$searchword.amp;whatever=.$whatever);//add
 the other variables to pass to next page in a similar fashion
echo tabletrtd.$hstring./td/tr;
while($row = mysql_fetch_array($result)){
   echo trtd.$show_data_here./td/tr;
}
echo trtd.$pstring./td/tr/table;
}
?
Note: the search variables on subsequent pages will be passed by GET method








-- 
regards,
Tom


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