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!
Text limit? Next page?
Moderator: General Moderators
What he's saying is, try something like this:
First, create links like this.
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!
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
*/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.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
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: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";
http://www.mysql.com/doc/en/String_func ... ml#IDX1185
Mac