Jump to content

[SOLVED] order by date and limit


runei

Recommended Posts

Hello. I have got a fraction of the script showing under. The limit funtion sort of works but it only returns one id for every category. As it is it should return two right? I also need help on how you go about extracting eg; the first three lines from a field in the table. If the field is a message field in a forum the user might write a long entry, and i do not want the whole entry showing on the frontpage, just the last two entries and eg; the 3-4 first lines of the message.

 

 $sql7 = "SELECT * FROM forum_topics WHERE categoryid ='".$row3['id']."'ORDER BY date DESC LIMIT 0, 2";
				 $result7 = mysql_query($sql7) or die (mysql_error());
				 if (mysql_num_rows($result7)== 0){
					echo "error";
				}else{
					$row7 = mysql_fetch_assoc($result7);
					echo "'".$row7['id']."'";
				}

 

thx

runei

Link to comment
https://forums.phpfreaks.com/topic/131514-solved-order-by-date-and-limit/
Share on other sites

Not sure what you're asking for but as fgor only displaying the first couple of lines of text why not extract the first x number of characters from the text and display that?

http://uk2.php.net/manual/en/function.substr.php

 

Something like this to display the first 300 characters:

echo trim(substr($txt,0,300));

trim() is used just in case there's a space or carriage return on the end.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.