PDA

View Full Version : LIMIT?



Independent
26-06-2008, 07:49 PM
How do you make PHP show only 20 of the newest fields on the page, but still able to check which username the comment is for, the current code is;



if($_POST[comment]) {
$message = silence($_POST['little']);
mysql_query("INSERT INTO comments (`from`, `for`, `message`, `date`) VALUES('$nivusr', '$propername', '$message', '$time')") or die(mysql_error());
print("<br /><br /><b>Your comment has been added.. please wait a couple of seconds!</b><meta http-equiv=\"refresh\" content=\"1\"/>");
}
}
else {
while($showcomments = mysql_fetch_array($commentcheck)) {

$commentfrom = ($showcomments['from']);
$commentmessage = ($showcomments['message']);
$commentdate = ($showcomments['date']);

$getmyfriendsimg = mysql_query("SELECT * FROM profile WHERE `name` = '$commentfrom' ORDER BY `id`");
while($showmyfriendsimg = mysql_fetch_array($getmyfriendsimg)) {

$shiwmymatesava = ($showmyfriendsimg['myimg']);
$shiwmymatename = ($showmyfriendsimg['name']);

echo('<table width="800" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td valign="top" width="50" height="1"><a href="http://www.nivade.com/profile/'.$commentfrom.'"><img border="0" img width="50" height="50" src="'.$shiwmymatesava.'"></a></td>
<td valign="top" width="700" height="12"><a href="http://www.nivade.com/profile/'.$commentfrom.'">'.$commentfrom.'</a></b><br /><font color="'.$fontcolor.'" face="'.$font.'">'.$commentmessage.'<br /></td>
</tr>
</table><br />');
}

Protege
26-06-2008, 10:58 PM
"LIMIT 0, 20" In the mysqlQuery, and you need to paste the whole page as I can't under some of it, well most of it cause its so badly coded but yeah...

You could limit like this, but this is a dumb way


while ( $your_mum <= 20 )
{
$your_mum++;
$comment = $mysqlFetch[ 'comment' ];
$comment_name = $mysqlFetch[ 'name' ];
}
echo( 'Just echoed 20 of your_mums_so_fit comments' );

Want to hide these adverts? Register an account for free!