[英]Pull 4 table rows from MySQL table and display with PHP on a page?
I need to simply Pull 4 table rows from MySQL table and display with PHP on a page? 我只需要从MySQL表中提取4个表行并在页面上显示PHP? Can someone help me with this code... All I have is:
有人可以帮我这个代码吗...我所拥有的是:
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 HTML
<?php echo mysql_result('tablerow'); ?>
Here is some code that should get you started! 这是一些应该让您入门的代码!
$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);
Just replace yourrow
with the name of the row that you want to print out! 只需更换
yourrow
与要打印出该行的名字! Don't forget to set the variables $host
$user
$pass
and $table
不要忘记设置变量
$host
$user
$pass
和$table
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.