Page 1 of 1

MYSQL Display

Posted: Wed Jul 11, 2007 12:21 pm
by Suraski
I want to only display only 10 MYSQL rows instead of all of the rows in the table, what's the code?

Posted: Wed Jul 11, 2007 12:28 pm
by guitarlvr
haha. good luck getting code that way.

Posted: Wed Jul 11, 2007 12:37 pm
by Suraski
ok, here's my current code. I want to display only ten rows from the table, can you help me out?

Code: Select all

mysql_select_db("news", $con);
$result = mysql_query("SELECT * FROM news");
while($row = mysql_fetch_array($result))
{
if ( $row['cat'] == News){
echo "				<table bgcolor=\"#FFF7CA\" width=\"500\" height=\"100\" cellpadding=\"0\" cellspacing=\"0\" style=\"border: 1px solid #FFD460; margin: 10px; padding: 0;\" >
					<tr>
          				<td valign=\"top\" height=\"15\" style=\"padding: 3px 3px 3px 5px ; border-bottom: 1px solid #FFD460\">
							<d1head> News: &nbsp;" . $row['title'] . "</d1head>
		  				</td>
					</tr>
					<tr>
						<td valign=\"top\" height=\"20\" style=\"padding: 10px\"
							<t2>" . $row['news'] . "</t2><t2><br /> 
							<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $row['name'] . "</t2>										
						</td>
					</tr>
					<tr>
						<td valign=\"top\" height=\"20\" style=\"border-top: 1px solid #FFD460\">
							<t2>" . $row['date'] . "</t2>						
						</td>
					</tr>
				</table>
		";
}
else{
echo "				<table bgcolor=\"#FAF0FF\" width=\"500\" height=\"100\" cellpadding=\"0\" cellspacing=\"0\" style=\"border: 1px solid #EC9EFF; margin: 10px; padding: 0;\" >
					<tr>
          				<td valign=\"top\" height=\"15\" style=\"padding: 3px 3px 3px 5px ; border-bottom: 1px solid #EC9EFF\">
							<d1head> Blog: &nbsp;" . $row['title'] . "</d1head>
		  				</td>
					</tr>
					<tr>
						<td valign=\"top\" height=\"20\" style=\"padding: 10px\"
							<t2>" . $row['news'] . "</t2><t2><br /> 
							<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $row['name'] . "</t2>										
						</td>
					</tr>
					<tr>
						<td valign=\"top\" height=\"20\" style=\"border-top: 1px solid #EC9EFF\">
							<t2>" . $row['date'] . "</t2>						
						</td>
					</tr>
				</table>
		";
}
}
mysql_close($con);

Posted: Wed Jul 11, 2007 3:01 pm
by feyd
LIMIT 10.

Posted: Wed Jul 11, 2007 5:27 pm
by RobertGonzalez

Posted: Thu Jul 12, 2007 10:13 am
by Suraski
Thx everybody