我需要简单地从MySQL表中拉出4个表行并在页面上用PHP显示?有人可以帮我解决这个问题...我只有:
include_once ('db.php');
$link = mysql_connect($db,$user,$pass) or die("Can't connect to Database");
mysql_select_db($table,$link);
/* Main */
$query="SELECT * FROM $subtable ORDER BY id DESC LIMIT 1";
$result=mysql_query($query);
HTML
<?php echo mysql_result('tablerow'); ?>
答案 0 :(得分:1)
以下是一些可以帮助您入门的代码!
$link = mysql_connect($host,$user,$pass,$table);
$loop = mysql_query($link,"SELECT * FROM $subtable ORDER BY id DESC LIMIT 4");
while ($row = mysql_fetch_array($loop))
{
echo $row['yourrow']."<br/>";
}
mysql_close($link);
只需将yourrow
替换为您要打印的行的名称!不要忘记设置变量$host
$user
$pass
和$table