Re: result set in php pagination

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Joe Keenan wrote:
Thanks very much Bastien. I haven't the faintest idea why but that simple change in the code sorted all of this. The pagination links now follow through with the complete result set of my query.

I will now have to read around this to discover why the change works.

By putting it in the url means it's not a POST variable any more, it is now a GET variable.

REQUEST covers both (and more) - so if it appears in GET, it will be set to that. If it appears in POST, it'll use that instead.

Also nobody's mentioned you should use mysql_real_escape_string when you do your query otherwise your site will (eventually) have problems with sql injection.

$query = "SELECT article_id, author_name, category_name, title,
article_caption, date_format(magazine_date, '%M, %Y') as newdate
FROM articles WHERE author_name = '$author_name' ORDER BY
magazine_date ASC LIMIT $offset, $rowsperpage";

becomes:

$query = "SELECT article_id, author_name, category_name, title,
article_caption, date_format(magazine_date, '%M, %Y') as newdate
FROM articles WHERE author_name = '" . mysql_real_escape_string($author_name) . "' ORDER BY
magazine_date ASC LIMIT $offset, $rowsperpage";

You won't see much difference if you print it out but if you put things like a single quote in your name search, it will be handled now and not cause a mysql error.


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


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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux