Page 1 of 1
Text limit? Next page?
Posted: Sun Apr 27, 2003 11:27 pm
by Mr. Tech
Hi!
I have an article script. Now what I want to do to it is when there is more then a certain number or words or charaters, it would put the rest of the article on the next page. Understand what I mean?
Thanks for any help!
Posted: Mon Apr 28, 2003 7:48 am
by praveen
Try to use this kind of query.
select * from article ORDER BY id DESC limit $min,10;
I used the above script to list ten users at a time.
Posted: Mon Apr 28, 2003 12:47 pm
by Jim
What he's saying is, try something like this:
First, create links like this.
Code: Select all
<a href='index.php?add=0'> //For articles 1-10
<a href='index.php?add=10'> //For articles 10-20
<a href='index.php?add=20'> //For articles 20-30
// Etc., Etc.
// Set $min and add
$add = $_GET['add'];
$min = 0 + $add;
// Select Statement
$sql = "select * from article ORDER BY id DESC limit $min , 10";
$act = mysql_query($sql);
/*
Rest of PHP Code
*/
Now to explain it. In the URL, the variable "add" is set. "Add" is added to the variable $min which is then put in the SQL statement.
For the first link, $add = 0. Therefore, $num = 0 + 0 = 0. This will force the SQl statement to pull articles with ids between 0 and 10.
The next link, $add = 10. Therefore, $num = 0 + 10 = 10. This will force the SQL statement to pull articles with ids between 10 and 20.
And this goes on and on and on and on and on.

Hope that helps!
Posted: Mon Apr 28, 2003 5:10 pm
by Mr. Tech
so in the query this makes it limit the amount of text:
$sql = "select * from article ORDER BY id DESC limit
$min , 10";
Thanks

Posted: Tue Apr 29, 2003 2:38 pm
by twigletmac
Mr. Tech wrote:so in the query this makes it limit the amount of text:
$sql = "select * from article ORDER BY id DESC limit $min , 10";
No it doesn't - the suggestions you've had are for limiting the number of results returned not the number of characters of text. To limit characters, take a look at:
http://www.mysql.com/doc/en/String_func ... ml#IDX1185
Mac
Posted: Wed Apr 30, 2003 1:32 am
by Mr. Tech
Thanks.
This it:
SUBSTRING(str,pos)