PHP怎么输出数据?

发布网友

我来回答

3个回答

热心网友

<?php
$db=mysql_connect( 'localhost', '用户名', '密码' );
mysql_select_db('test',$db);
$query=mysql_query("select * from test");

while($rs=mysql_fetch_array($query))
{
?>
<table>
<tr>
<td><?php echo $rs['id']?></td>
<td><?php echo $rs['title']?></td>
<td><?php echo $rs['content']?></td>
</tr>
</table>

<?php
}
?>

热心网友

先连接数据库然后
<table>
<tr>
<td>ID</td>
<td>title</td>
<td>content</td>
</tr>
<?
$sql="select * from user_name";
$res=mysql_query($sql);
while ($arr=mysql_fetch_array($res)){?>
<tr>
<td><? echo $arr[id];?></td>
<td><? echo $arr[title];?></td>
<td><? echo $arr[content];?></td>
</tr>
<? }?>
</table>

热心网友

echo
print();
print_r();
var_mp();

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com