PHP/MySQL查询-显示数据刷新器[代码语法正确吗?]
这是我在localhost上的一个在线电台站点上的页面,它是一个用于测试的基本PHP/MySQL页面:PHP/MySQL查询-显示数据刷新器[代码语法正确吗?],php,mysql,echo,Php,Mysql,Echo,这是我在localhost上的一个在线电台站点上的页面,它是一个用于测试的基本PHP/MySQL页面: <?php mysql_connect('localhost', 'root', 'mypass') or die (mysql_error()); mysql_select_db('radiotest') or die (mysql_error()); $result = mysql_query("SELECT *, TIME_FORMAT(airtime, '%H:%i')
<?php
mysql_connect('localhost', 'root', 'mypass') or die (mysql_error());
mysql_select_db('radiotest') or die (mysql_error());
$result = mysql_query("SELECT *, TIME_FORMAT(airtime, '%H:%i') `airtime`
from presenters");
//Table starting tag and header cells
while($row = mysql_fetch_array($result)){
//Display the results in different cells
echo "<dd><dl><img src=' " . $row['image'] . " '>" . $row['airtime'] ."
" . $row['presenter'] . "</dd></dl>";
echo "<dd><dl>" . $row['showinfo'] . "</dd></dl>";
}
?>
它工作正常,以所需格式显示表中的数据
但是,我想尝试这样做:
<dd><dl><img src='<?php echo $row['image'] ?'> <?php echo $row['airtime']?>
<?php echo. $row['presenter']?> </dd></dl>
我的问题是:我承认我忘记了如何在不在上面的PHP/MySQL查询中显示echo,那么如何确保它使用echo显示变量而不必在MySQL连接中声明它呢?我知道我的原稿格式正确,但我不希望它在语法的while部分之后包含echo变量,我希望在dd/dl HTML(定义列表)中对它们进行回显
基本上,我只是想提高我在这方面的技能;我看过谷歌,但不太确定
感谢您的帮助 这真的没有什么不同,也肯定没有更好,但我想你是在要求做:
while($row = mysql_fetch_array($result)){
//Display the results in different cells
?>
<dd><dl>
<img src='<?php echo $row['image']; ?>'>
<?php echo $row['airtime']; ?> <?php echo $row['presenter']; ?>
</dd></dl>
<dd><dl>'<?php echo $row['showinfo']; ?></dd></dl>
<?php
}
while($row=mysql\u fetch\u array($result)){
//在不同的单元格中显示结果
?>
'>
'
请尝试以下方法:
<dd>
<dl>
<img src='<?=$row['image'] ?>'> <?=$row['airtime'] . " - " .$row['presenter']?>
</dd>
</dl>
'>
您的代码看起来已经格式化,我不知道您想问什么。短标记真的有必要吗?短标记有什么问题吗?我不是按代码长度付费的:)