[PHP] mod rewrite - DMXzone's PHP Pagination

2010-11-16 Thread Richard West
Hello Guys, Gals,
I've been working on a project of mine creating a custom little cms. I've 
managed to go by tutorials and reference material from the php site to get as 
far as I have. I've got search engine friendly links working with mod rewrite 
using mysql entry of page alias and my code is like /.html

Now that was simple to what I have ran into...

DMXzone has a dreamweaver extension called PHP Pagination which creates very 
nice paging links. But it has a huge class and its function to print links is 
over my head. I'm new to the list and I know how aggravating it can be to 
volunteer help and I give everyone many thanks that makes the effort to help 
others. I'm sure you all are blessed in many ways.

Can a new guy to the list just jump right in and ask for help? - lol

If someone here a guru at mod_rewrite, please help me get through this step 
because i'm stuck...

My url to my integrated blog is
/blog.html

after click pagination
/blog.html?pageNum_rsBlog=1

my htaccess I have added

RewriteEngine on 
RewriteRule blog-(.*).html$ /blog.html?pageNum_rsBlog=$1


my link should end up
/blog-1.html

I hope its ok to post this long function
here is the dmxzone function inside pagination class

function addPagination()
{
$pageNo = 1;
$recPerPage = 1;
if ($this->recordsetName != "") {
$dsName = $this->recordsetName;
$offsetName = "pageNum_";
$useOffset = 0;
} else {
$dsName = $this->feedGenieName;
$offsetName = "offset_";
$useOffset = 1;
$recPerPage = $this->rowsPerPage;
}

$this->numPages = ceil($this->rowsTotal / $this->rowsPerPage);
if ($this->numPages < 2)
{
return;
}

$curPageUrl = substr("/blog.html", strrpos("/blog.html", "/") +1);
// $curPageUrl = substr($_SERVER['PHP_SELF'], 
strrpos($_SERVER['PHP_SELF'], "/") +1);

if (isset($_GET[$offsetName.$dsName]))
{
if ($useOffset == 0) {
$pageNo = intval($_GET[$offsetName.$dsName]) + 1;
} else {
$pageNo = (intval($_GET[$offsetName.$dsName]) / 
$this->rowsPerPage) + 1;
}
}
$pageNumParam = $offsetName.$dsName."=";
$curPageUrl .= "?";

$queryString = "";
if (!empty($_SERVER['QUERY_STRING'])) 
{
  $params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) 
{
if (stristr($param, $offsetName.$dsName) == false && 
stristr($param, "totalRows_".$dsName) == false) 
{
array_push($newParams, $param);
}
}
if (count($newParams) != 0) 
{
$queryString = "&" . htmlentities(implode("&", $newParams));
  }
}
echo "";
if ($this->showFirstLast)
{
if ($pageNo == 1)
{
echo "".$this->firstLabel."";
}
else
{
$prev = $pageNo - 1;
echo "".$this->firstLabel."";
}
}
if ($this->showNextPrev)
{
if ($pageNo == 1)
{
echo "".$this->prevLabel."";
}
else
{
$prev = $pageNo - 1;
echo "".$this->prevLabel."";

}
}
if($this->numPages < (($this->outerLinks + $this->adjacentLinks)*2 + 1))
{
for ($i = 1; $i < $this->numPages + 1; $i++)
{
if ($pageNo == $i)
{
echo "".$i."";
}
else
{
echo "".$i."";
}
}
}
else
{
if($pageNo < $this->outerLinks + $this->adjacentLinks + 2)
{
for ($i = 1; $i < ($this->outerLinks + $this->adjacentLinks*2 + 
2); $i++)
{
if ($pageNo == $i)
{
echo "".$i."";
}
else
{
echo "".$i."";
}
}
  

Re: [PHP] Pagination?

2010-06-09 Thread Sharl.Jimh.Tsin
yes,LIMIT for mysql is useful.

Best regards,
Sharl.Jimh.Tsin



2010/6/8 Ashley Sheridan :
> On Tue, 2010-06-08 at 11:37 -0300, Paul Halliday wrote:
>
>> I just spent the last 1/2 hour looking at many different solutions for
>> this. Is there a universal favorite?
>>
>> Thanks.
>>
>
>
> It depends what you mean by pagination, as there are two parts to it.
> There is the display of the pagination nav and then the retrieval of
> paginated results:
>
> Use LIMIT in the SQL to paginate the data retrieved. I usually just use
> a few variables to determine the pagination display; $current_page,
> $items_per_page, $total_pages (which can be got by issuing a COUNT() in
> the SQL for all possible records that match.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

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



Re: [PHP] Pagination?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 11:37 -0300, Paul Halliday wrote:

> I just spent the last 1/2 hour looking at many different solutions for
> this. Is there a universal favorite?
> 
> Thanks.
> 


It depends what you mean by pagination, as there are two parts to it.
There is the display of the pagination nav and then the retrieval of
paginated results:

Use LIMIT in the SQL to paginate the data retrieved. I usually just use
a few variables to determine the pagination display; $current_page,
$items_per_page, $total_pages (which can be got by issuing a COUNT() in
the SQL for all possible records that match.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Pagination?

2010-06-08 Thread Paul Halliday
I just spent the last 1/2 hour looking at many different solutions for
this. Is there a universal favorite?

Thanks.

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



Re: [PHP] pagination code not incrementing page numbers.

2006-10-23 Thread Chris

Mark wrote:

I am using the following code for pagination with php5 and mysql 4.1.x
The pages advance by clicking on the "Next" or "Last" link

However the url does not advance past this in the url field
http://localhost/page.php?pagenum=2

Also the page count does not increase past
"--Page 1 of 50--" at the bottom of the page regardless of how many 
pages forward I have clicked.


If anyone could point me in the right direction to fix this, it would be 
much appreciated.


Code:

// Connects to your Database
mysql_connect("dev", localhost", "user", "password") or die(mysql_error());
mysql_select_db("mydatabase") or die(mysql_error());

//This checks to see if there is a page number. If not, it will set it 
to page 1

if (!(isset($pagenum)))
{
$pagenum = 1;
}


if (!isset($_GET['pagenum'])) {
  $pagenum = 1;
} else {
  $pagenum = (int)$_GET['pagenum'];
}

You have register_globals off (good thing) so you need to change how you 
fetch the information.


If it's in the url, it'll be in $_GET somewhere.

This:
$pagenum = (int)$_GET['pagenum'];

Will make sure that $pagenum is a number so I can't change it:

...?pagenum=alert('xyz');


--
Postgresql & php tutorials
http://www.designmagick.com/

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



[PHP] pagination code not incrementing page numbers.

2006-10-23 Thread Mark

I am using the following code for pagination with php5 and mysql 4.1.x
The pages advance by clicking on the "Next" or "Last" link

However the url does not advance past this in the url field
http://localhost/page.php?pagenum=2

Also the page count does not increase past
"--Page 1 of 50--" at the bottom of the page regardless of how many 
pages forward I have clicked.


If anyone could point me in the right direction to fix this, it would be 
much appreciated.


Code:

// Connects to your Database
mysql_connect("dev", localhost", "user", "password") or die(mysql_error());
mysql_select_db("mydatabase") or die(mysql_error());

//This checks to see if there is a page number. If not, it will set it 
to page 1

if (!(isset($pagenum)))
{
$pagenum = 1;
}

//Here we count the number of results
//Edit $data to be your query
$data = mysql_query("SELECT * FROM main") or die(mysql_error());
$rows = mysql_num_rows($data);

//This is the number of results displayed per page
$page_rows = 8;

//This tells us the page number of our last page
$last = ceil($rows/$page_rows);

//this makes sure the page number isn't below one, or more than our 
maximum pages

if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}

//This sets range that we will display in our query
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;

//This is your query again, the same one... the only difference is we 
add $max into it

$data_p = mysql_query("SELECT * from main $max") or die(mysql_error());

//This is where you display your query results
while($info = mysql_fetch_array( $data_p ))
{

Print $info['id'];
echo "";
Print $info['bio'];
echo "";
}

echo "";

// This shows the user what page they are on, and the total number of pages
echo " --Page $pagenum of $last-- ";

// First we check if we are on page one. If we are then we don't need a 
link to the previous page or the first page so we do nothing. If we 
aren't then we generate links to the first page, and to the previous page.

if ($pagenum == 1)
{
}
else
{
echo "  <<-First ";
echo " ";
$previous = $pagenum-1;
echo "  <-Previous ";
}

//just a spacer
echo "  ";


//This does the same as above, only checking if we are on the last page, 
and then generating the Next and Last links

if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " Next -> ";
echo " ";
echo " Last ->> ";
}
?>

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



Re: [PHP] Pagination

2005-03-25 Thread Colin Ross
watch out for SQL injection attacks on that one though:

what if the 'user' went to "page.php?start=1;SELECT * from `mysql`;


On Thu, 24 Mar 2005 22:55:01 +0100, pavel <[EMAIL PROTECTED]> wrote:
> > I am wanting to paginate records from a MySQL Database.
> > I want there to be 5 records on a page, on multiple pages.
> 
> example for selecting page of records from mysql table:
> $sql=sprintf("
> SELECT SQL_CALC_FOUND_ROWS * FROM table LIMIT %d, %d",
> $position*$records,
> $records
> );
> 
> after get count of all records:
> $sql='SELECT FOUND_ROWS()';
> 
> > (I would like there to be a "next" and "previous.")
> 
> you can use http://pear.php.net/package/Pager
> 
> --
> Pavel Vrany
> http://ogi.cz/
> 
> --
> 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



Re: [PHP] Pagination

2005-03-24 Thread pavel
> I am wanting to paginate records from a MySQL Database.
> I want there to be 5 records on a page, on multiple pages.

example for selecting page of records from mysql table:
$sql=sprintf("
SELECT SQL_CALC_FOUND_ROWS * FROM table LIMIT %d, %d",
$position*$records,
$records
);

after get count of all records:
$sql='SELECT FOUND_ROWS()';

> (I would like there to be a "next" and "previous.")

you can use http://pear.php.net/package/Pager

-- 
Pavel Vrany
http://ogi.cz/

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



RE: [PHP] Pagination

2005-03-23 Thread Chris W. Parker
Marquez Design 
on Wednesday, March 23, 2005 12:19 PM said:

> I am wanting to paginate records from a MySQL Database.
> I want there to be 5 records on a page, on multiple pages.
> 
> Can someone point me in the right direction or show me a way to do
> this? 
> 
> I can get five records on a page with a LIMIT statement, however, I
> can not get it to show the first five, then put a "next" link to the
> next 5 and so on.

Since you're already using limit you're doing better than most.

At this point you can do one of two things:

1. When the search is first executed get a count of all available
records and display only the ones you want on your page. On each
subsequent page (next/previous) return, using the LIMIT clause, only
those records you need.

With this technique you'll be able to show the user how many total pages
there are instead of the using guessing as to when they'll reach the end
of their search results. If you don't have a lot of results you might
not care to go this route.

One requirement with this option is that you must pass the total number
of records during each next/previous page transition. This is to tell
the page that you've already done the initial look up.

2. Use the LIMIT clause to return only the records you need.

This is what you seem to be doing already. The only other piece to your
puzzle is to send the starting point for the LIMIT clause on each page
change.

For the first page you probably had "SELECT ... FROM ... LIMIT 0,5".
Considering we're on the first page the "previous" link will not be
clickable since we can't go back any further. However, the "next" link
will pass the value 5 to the page so that the limit clause knows to
start at record 5 on the next pass. i.e. "SELECT ... FROM ... LIMIT
5,5".

So...

Page 0:

previous
next

Page 1:

previous
next

Page 2:

previous
next

etc.

Of course, you'll need to pass all your search criteria (and any other
data you need) within each link as well.



HTH!
Chris.

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



Re: [PHP] Pagination

2005-03-23 Thread John Nichel
Please send replies to the list.
[EMAIL PROTECTED] wrote:
I've been working on this same project for one of my pages, and it seems 
relatively straight forward if you are just using a full set of records 
to paginate, but if you are using a filtered set (or search results) 
then it becomes a bit more tircky to ascertain where in the search 
results you are.  I'm still working on that, and reading this thread 
intently.

Thanks,
*/
Martin Austin
/*
*John Nichel <[EMAIL PROTECTED]>*
Marquez Design wrote:
 > Hello all,
 >
 > I am wanting to paginate records from a MySQL Database.
 > I want there to be 5 records on a page, on multiple pages.
 >
 > Can someone point me in the right direction or show me a way to do this?
 >
 > I can get five records on a page with a LIMIT statement, however, I 
can not
 > get it to show the first five, then put a "next" link to the next 5 
and so
 > on.
 >
 > (I would like there to be a "next" and "previous.")

Your next and previous buttons either need to pass where they left off
in the db (either in the query string or by means of a form post), so
that your script will know where to start from.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Pagination

2005-03-23 Thread John Nichel
Marquez Design wrote:
Hello all,
I am wanting to paginate records from a MySQL Database.
I want there to be 5 records on a page, on multiple pages.
Can someone point me in the right direction or show me a way to do this?
I can get five records on a page with a LIMIT statement, however, I can not
get it to show the first five, then put a "next" link to the next 5 and so
on.
(I would like there to be a "next" and "previous.")
Your next and previous buttons either need to pass where they left off 
in the db (either in the query string or by means of a form post), so 
that your script will know where to start from.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Pagination

2005-03-23 Thread Marquez Design
Hello all,

I am wanting to paginate records from a MySQL Database.
I want there to be 5 records on a page, on multiple pages.

Can someone point me in the right direction or show me a way to do this?

I can get five records on a page with a LIMIT statement, however, I can not
get it to show the first five, then put a "next" link to the next 5 and so
on.

(I would like there to be a "next" and "previous.")

Thank you for any help.

--
Steve

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



[PHP] Pagination Optimization

2005-01-07 Thread Bruno B B Magalhães
Hi guys,
currently I have a function in my framework´s mysql driver , that fetch 
paginated results... Here it´s:

===
/*
*  Fetch paginated results
*/
function fetch_paginated($query='',$page=1,$itens=20)
{
$this->query($query.' LIMIT 
'.(($page*$itens)-$itens).','.$itens);

if($this->num_rows() > 0)
{
while($this->fetch_array())
{
$results[] = $this->row;
}
}
else
{
return null;
}

$this->query($query.' LIMIT 0,'.(($page*$itens)-$itens));
$this->pages_before = ceil($this->num_rows()/$itens);

$this->query($query.' LIMIT 
'.($page*$itens).',100');
$this->pages_after = ceil($this->num_rows()/$itens);

$this->query($query);
$this->total_pages = ceil($this->num_rows()/$itens);

return $results;
}
===
My question is: Is there ANY way to speed up this function, or any way 
to fetch paginated results quicker? I had a project list, without 
pagination, and when I added the pagination function, it slowed down up 
to 0.0125 secs. Before it was running at 0.0600 more or less, and now 
it´s running at 0.07 to 0.075...

Best Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Pagination need help again

2004-11-13 Thread Scott McWhite








Sorry,

 

It’s me again.  I tried all the recommendations from
my first responses and could not find the proper syntax on how to use it in my
file.    My original email question,error, and my php code is listed below.  Thank
you in advance for all your help, this is a great community.

 

Original Question?  Previous email subject:
Pagination need help.

 

I’m using an HTML
search form that passes the “searchterm” to a php file.

In my case the
“searchterm” can have 1000s of records in my database, so I implemented
a limit which displays 20 records per page.  The pagination function works fine
with one exception.  Example of my problem: searchterm typed in the html search
form equals “ford”, in the database there are 2000 fords, the first
page displays 20 fords and then the next page forgets that we are searching
“fords” and displays the equivalent to a wildcard “%”

search and displays
accordingly.  

 

Does anyone have sample code
for using an HTML search form with pagination?

Generally what I’m
trying to do is type a “searchterm” on the html search page, have
the php file run the query and if it is an item that has many results to
display it 20 records per page without it displaying every record in the
database.

 

Error.

 

Notice: Undefined index: searchterm in C:\Inetpub\cars\search\my_php_file.php on
line 2

Notice: Undefined index:
searchterm1 in C:\Inetpub\cars\search\my_php_file.php
on line 3

Notice: Undefined index:
searchterm2 in C:\Inetpub\cars\search\my_php_file.php
on line 4

 

 

My php file. Attached also if not displayed in email
properly.

 



$searchterm=$_POST['searchterm'];

$searchterm1=$_POST['searchterm1'];

$searchterm2=$_POST['searchterm2'];

 

$searchterm =
addslashes($searchterm);

$searchterm1 =
addslashes($searchterm1);

$searchterm2 =
addslashes($searchterm2);

 

 

@mysql_pconnect("localhost",
"root", "") or die("error -- can't connectto
server");

@mysql_select_db("list")
or die ("error -- can't connect to DB");

 

 

if(!isset($_GET['page'])){

$page = 1;

} else {

$page = $_GET['page'];

}

 

// Define the number of
results per page

$max_results = 20;

 

// Figure out the limit for
the query based

// on the current page
number.

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

 

// Perform MySQL query on
only the current page number's results

 

$sql  = "select * from
parts where ".'model'." like '%".$searchterm."%' AND
".'seller'." like '%".$searchterm1."%' AND
".'description'." like '%".$searchterm2."%' ORDER BY
'model', 'price', 'quantity' LIMIT $from, $max_results";

 

echo '';

 

$result = mysql_query($sql)
or die(mysql_error());

$numofrows =
mysql_num_rows($result);

echo "\n";

echo "SellerModel NumberManufacturerDescriptionQuantityPriceConditionEmail
AddressAIM\n";

for($i = 0; $i <
$numofrows; $i++) {

$row =
mysql_fetch_array($result); //get a row from our result set

if($i % 2) { //this means if
there is a remainder

echo "\n";

} else { //if there isn't a
remainder we will do the else

echo "\n";

}

echo "".$row['seller']."".$row['model']."".$row['manufacturer']."".$row['description']."".$row['quantity']."".$row['price']."".$row['condition']."".$row['email']."AIM
Link\n";

echo
"\n";

}

//now let's close the table
and be done with it

echo
"\n";

 

while($row =
mysql_fetch_array($result)){

// Build your formatted
results here.

$variable1=$row["manufacturer"];

$variable2=$row["seller"];


$variable3=$row["model"];


$variable4=$row["description"];

$variable5=$row["email"];

 

//results

 

print
("");

print ("$variable1");

print ("$variable2"); 

print ("$variable3"); 

print ("$variable4");

print ("$variable5"); 

print
(""); 

}

 

 

// Figure out the total
number of results in DB:

$total_results =
mysql_result(mysql_query("SELECT COUNT(*) as Num FROM parts where
".'model'." like '%".$searchterm."%' AND
".'seller'." like '%".$searchterm1."%' AND
".'description'." like '%".$searchterm2."%'"),0);

 

// Figure out the total
number of pages. Always round up using ceil()

$total_pages =
ceil($total_results / $max_results);

 

// Page Number Hyperlinks

echo "Select a
Page";

 

// Previous Link

if($page > 1){

$prev = ($page - 1);

echo "

}

 

for($i = 1; $i <=
$total_pages; $i++){

if(($page) == $i){

echo
"$i
";

} else {

echo "

}

if(($i + 30) % 30 == 0)

{

echo
'';

}

}

 

// Next Link

if($page < $total_pages){

$next = ($page + 1);

echo "

}

echo
"";

 

?> 

 

 

Thank you,

 

Scott

 

 

 






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

Re: [PHP] Pagination need help

2004-11-04 Thread Mike
on 11/3/04 11:22 PM, Scott McWhite at [EMAIL PROTECTED] wrote:

> Does anyone have sample code for using an HTML search form with pagination?

Scott,

I followed this tutorial and it helped me accomplish what you are trying to
do.

http://www.phpfreaks.com/tutorials/43/0.php

Good luck.





++
Mike Yrabedra 
[EMAIL PROTECTED] 
Your Mac Intelligence Resource
++
W: http://www.macagent.com/
E: [EMAIL PROTECTED]

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



Re: [PHP] Pagination need help1)

2004-11-04 Thread Sebastiano Cascione
Use 2 queries.

1) SELECT * FROM cars WHERE ... ORDER BY... ";
1) SELECT * FROM cars WHERE ... ORDER BY... LIMIT $record_x_page OFFSET 
$page";

With the firsth query print pages numbers at the bottom of the html 
page.
With the second one print the records list.
Every time you click on the page number printed at the bottom you have to pass 
the searchterms (by get with urlencode()) to the 2 queries and the $page 
parameter.

Sebastiano



Alle 05:22, giovedì 4 novembre 2004, Scott McWhite ha scritto:
> Hi,
>
>
>
> I’m using an HTML search form that passes the “searchterm” to a php file.
> In my case the “searchterm” can have 1000s of records in my database, so I
> implemented a limit which displays 20 records per page.  The pagination
> function works fine with one exception.  Example of my problem: searchterm
> typed in the html search form equals “ford”, in the database there are 2000
> fords, the first page displays 20 fords and then the next page forgets that
> we are searching “fords” and displays the equivalent to a wildcard “%”
> search and displays accordingly.
>
>
>
> Does anyone have sample code for using an HTML search form with pagination?
> Generally what I’m trying to do is type a “searchterm” on the html search
> page, have the php file run the query and if it is an item that has many
> results to display it 20 records per page without it displaying every
> record in the database.
>
>
>
> Here is some of the code:
>
> $searchterm=$_POST['searchterm'];
>
> $searchterm1=$_POST['searchterm1'];
>
> $searchterm2=$_POST['searchterm2'];
>
>
>
> $sql  = "select * from cars where ".'car'." like '%".$searchterm."%' AND
> ".'seller'." like '%".$searchterm1."%' AND ".'description'." like
> '%".$searchterm2."%' ORDER BY 'car', 'price' LIMIT $from, $max_results";
>
>
>
> Thank you.

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



Re: [PHP] Pagination need help

2004-11-03 Thread Jason Wong
On Thursday 04 November 2004 04:22, Scott McWhite wrote:

> function works fine with one exception.  Example of my problem: searchterm
> typed in the html search form equals “ford”, in the database there are 2000
> fords, the first page displays 20 fords and then the next page forgets that
> we are searching “fords” and displays the equivalent to a wildcard “%”
> search and displays accordingly.

You're most likely not propagating the search term to the following page(s). 

> Does anyone have sample code for using an HTML search form with pagination?

google?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
To be trusted is a greater compliment than to be loved.
*/

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



[PHP] Pagination need help

2004-11-03 Thread Scott McWhite
Hi,

 

I’m using an HTML search form that passes the “searchterm” to a php file.
In my case the “searchterm” can have 1000s of records in my database, so I
implemented a limit which displays 20 records per page.  The pagination
function works fine with one exception.  Example of my problem: searchterm
typed in the html search form equals “ford”, in the database there are 2000
fords, the first page displays 20 fords and then the next page forgets that
we are searching “fords” and displays the equivalent to a wildcard “%”
search and displays accordingly.  

 

Does anyone have sample code for using an HTML search form with pagination?
Generally what I’m trying to do is type a “searchterm” on the html search
page, have the php file run the query and if it is an item that has many
results to display it 20 records per page without it displaying every record
in the database.

 

Here is some of the code:

$searchterm=$_POST['searchterm'];

$searchterm1=$_POST['searchterm1'];

$searchterm2=$_POST['searchterm2'];

 

$sql  = "select * from cars where ".'car'." like '%".$searchterm."%' AND
".'seller'." like '%".$searchterm1."%' AND ".'description'." like
'%".$searchterm2."%' ORDER BY 'car', 'price' LIMIT $from, $max_results";

 

Thank you.

 



Re: [PHP] Pagination & MSSQL

2004-03-09 Thread Richard Davey
Hello Alex,

Tuesday, March 9, 2004, 3:11:54 PM, you wrote:

AH> I have searched for some references on pagination using mssql but have come
AH> up empty.

AH> I have looked at the tutorials on Zend and just about everywhere else but
AH> unfortunately they all use LIMIT in the sql statement and the closest thing
AH> to that in mssql is either TOP n, or SET ROWCOUNT which does me no good.

This should help:
http://rosca.net/writing/articles/serverside_paging.asp

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



[PHP] Pagination & MSSQL

2004-03-09 Thread Alex Hogan
Hi All,

 

I have searched for some references on pagination using mssql but have come
up empty.

 

I have looked at the tutorials on Zend and just about everywhere else but
unfortunately they all use LIMIT in the sql statement and the closest thing
to that in mssql is either TOP n, or SET ROWCOUNT which does me no good.

 

My thoughts were to bring in all the recordsets and parse through them line
by line to only show the ones that I want for the page that is displayed.
Part of my solution is below but I kekep getting this error;

 

Parse error: parse error, unexpected ')', expecting ';' in
D:\WWW\scriptgen\pagination_test.php on line 25

 

This is the code;

 

$limit = 10;

for ($i = 0; $i < $limit; $i++){ -- This is line 25

$name = mssql_result($i);

if($bgcolor == "#F2F7FF"){

$bgcolor = "#FF";

}

else{

$bgcolor = "#F2F7FF";

}

echo "$name\n";

}

 

Something wrong with my syntax?

 

 

alex hogan

 

P.S.  OP is original poster isn't it, damn..., I need to start drinking
decaf.



** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




RE: [PHP] Pagination Part 2

2003-03-13 Thread Ford, Mike [LSS]
> -Original Message-
> From: conbud [mailto:[EMAIL PROTECTED]
> Sent: 12 March 2003 19:12
> 
> 
> Hi, Ive been trying to get this to work but I keep getting this error
> 
> Parse error: parse error, unexpected $ in 
> /home/conbud/nrlug/test3.php 
> on line 72
> 
> line 72 is just the ending php bracket,

Well, this is a pretty cryptic PHP error message -- $ in this context just means "end 
of file" (similar to its use in preg/ereg patterns!).  The most likely cause of this 
is that you have an unmatched opening brace {.

>  heres what I got:
> 
>  
>  @mysql_connect(localhost, root, boing_boing) or 
> die("ERROR--CAN'T 
> CONNECT TO SERVER");
>  @mysql_select_db("nrlug") or die("ERROR--CAN'T CONNECT TO DB");
> 
>  $limit= 2;
>  $query_count= "SELECT lnkname FROM links";
>  $result_count= mysql_query($query_count);
>  $totalrows= mysql_num_rows($result_count);
> 
>  if(empty($page))
>  $page = 1;
> 
> 
>  $limitvalue = $page * $limit - ($limit);
>  $query = "SELECT * FROM links LIMIT $limitvalue, $limit";
>  $result= mysql_query($query) or die("Error: " . 
> mysql_error());
> 
>  if(mysql_num_rows($result) == 0)
>  echo("Nothing to Display!");
> 
>  $bgcolor = "#E0E0E0"; // light gray
> 
>  echo("");
> 
>  while($row = mysql_fetch_array($result)){

brace level: 1

>  if($bgcolor == "#E0E0E0")
>  $bgcolor = "#FF";
>  else
>  $bgcolor = "#E0E0E0";
> 
>  echo("\n");
>  echo($row['lnkname']);
>  echo("\n\");
>  echo($row['id']);
>  echo("\n");
>  }

brace level: 0

> 
>  echo("");
> 
>  if($page != '1'){

brace level: 1

>  $pageprev = $page--;
> 
>  echo("PREV ");
>  }else

brace level: 0

>  echo("PREV ");
> 
>  $numofpages = $totalrows / $limit;
> 
>  for($i = '1'; $i <= $numofpages; $i++){

brace level: 1

>  if($i == $page)
>  echo($i." ");
>  else
>  echo("$i ");
> 
> 
>  if(($totalrows % $limit) != '0'){

brace level: 2

>  if($i == $page)
>  echo($i." ");
>  else
>  echo("$i ");
> 
>  if(($totalrows - ($limit * $page)) > '0'){

brace level: 3

>  $pagenext = $page++;
> 
>  echo("NEXT");
>  }else

brace level: 2

>  echo("  NEXT ".$limit);
> 
>  mysql_free_result($result);
> 
> ?>

Uh -- brace level is still 2, which means you have 2 unclosed opening braces.  Put 
those in at the appropriate places (and your indentation is pretty suggestive of where 
that is!) and all should be fine.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


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



Re: [PHP] Pagination Part 2

2003-03-12 Thread Jonathan Pitcher
You are mixing and matching your If statements.

if ()

else

AND

if () {

} else {

}

Be consistent.  It looks like if you close the { tags your code should 
work ok.}

Hope this helps,

Jonathan Pitcher

On Wednesday, March 12, 2003, at 01:11  PM, conbud wrote:

Hi, Ive been trying to get this to work but I keep getting this error

Parse error: parse error, unexpected $ in /home/conbud/nrlug/test3.php 
on line 72

line 72 is just the ending php bracket, heres what I got:



@mysql_connect(localhost, root, boing_boing) or die("ERROR--CAN'T 
CONNECT TO SERVER");
@mysql_select_db("nrlug") or die("ERROR--CAN'T CONNECT TO DB");

$limit= 2;
$query_count= "SELECT lnkname FROM links";
$result_count= mysql_query($query_count);
$totalrows= mysql_num_rows($result_count);
if(empty($page))
$page = 1;
$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM links LIMIT $limitvalue, $limit";
$result= mysql_query($query) or die("Error: " . mysql_error());
if(mysql_num_rows($result) == 0)
echo("Nothing to Display!");
$bgcolor = "#E0E0E0"; // light gray

echo("");

while($row = mysql_fetch_array($result)){
if($bgcolor == "#E0E0E0")
$bgcolor = "#FF";
else
$bgcolor = "#E0E0E0";
echo("\n");
echo($row['lnkname']);
echo("\n\");
echo($row['id']);
echo("\n");
}
echo("");

if($page != '1'){
$pageprev = $page--;
echo("PREV ");
}else
echo("PREV ");
$numofpages = $totalrows / $limit;

for($i = '1'; $i <= $numofpages; $i++){
if($i == $page)
echo($i." ");
else
echo("$i ");
if(($totalrows % $limit) != '0'){
if($i == $page)
echo($i." ");
else
echo("$i ");
if(($totalrows - ($limit * $page)) > '0'){
$pagenext = $page++;
echo("NEXT");
}else
echo("  NEXT ".$limit);
mysql_free_result($result);

?>

--
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


[PHP] Pagination Part 2

2003-03-12 Thread conbud
Hi, Ive been trying to get this to work but I keep getting this error

Parse error: parse error, unexpected $ in /home/conbud/nrlug/test3.php 
on line 72

line 72 is just the ending php bracket, heres what I got:



@mysql_connect(localhost, root, boing_boing) or die("ERROR--CAN'T 
CONNECT TO SERVER");
@mysql_select_db("nrlug") or die("ERROR--CAN'T CONNECT TO DB");

$limit= 2;
$query_count= "SELECT lnkname FROM links";
$result_count= mysql_query($query_count);
$totalrows= mysql_num_rows($result_count);
if(empty($page))
$page = 1;
$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM links LIMIT $limitvalue, $limit";
$result= mysql_query($query) or die("Error: " . mysql_error());
if(mysql_num_rows($result) == 0)
echo("Nothing to Display!");
$bgcolor = "#E0E0E0"; // light gray

echo("");

while($row = mysql_fetch_array($result)){
if($bgcolor == "#E0E0E0")
$bgcolor = "#FF";
else
$bgcolor = "#E0E0E0";
echo("\n");
echo($row['lnkname']);
echo("\n\");
echo($row['id']);
echo("\n");
}
echo("");

if($page != '1'){
$pageprev = $page--;
echo("PREV ");
}else
echo("PREV ");
$numofpages = $totalrows / $limit;

for($i = '1'; $i <= $numofpages; $i++){
if($i == $page)
echo($i." ");
else
echo("$i ");
if(($totalrows % $limit) != '0'){
if($i == $page)
echo($i." ");
else
echo("$i ");
if(($totalrows - ($limit * $page)) > '0'){
$pagenext = $page++;
echo("NEXT");
}else
echo("  NEXT ".$limit);
mysql_free_result($result);

?>

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


Re: [PHP] pagination help

2003-03-09 Thread Kevin Waterson
This one time, at band camp,
"Denis L. Menezes" <[EMAIL PROTECTED]> wrote:

> Hello friends.

> Can someone give me a link to some help files?


http://www.phpbuilder.com/columns/rod20001214.php3

Kevin

-- 
 __  
(_ \ 
 _) )            
|  /  / _  ) / _  | / ___) / _  )
| |  ( (/ / ( ( | |( (___ ( (/ / 
|_|   \) \_||_| \) \)
Kevin Waterson
Port Macquarie, Australia

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



[PHP] pagination help

2003-03-09 Thread Denis L. Menezes
Hello friends.

My records on one page are bout 200. So I wish to paginate them and show only about 20 
records per page with the page numbers at the bottom of the records table and also the 
"previous" and "next" links.
I mean, something line Google's searcg results page numbering system.

Can someone give me a link to some help files?

Thanks
Denis