Re: [PHP-DB] result set in php pagination
[email protected] (Chris)
| Newsgroups | php.db |
|---|---|
| Message-ID | <[email protected]> |
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/