[英]echo php inside html
$rst=mysqli_query($link, "SELECT * FROM flux_receptie WHERE status_procesare ='PRELUAT' AND status_solutionare ='' ORDER BY ora_preluare DESC LIMIT 5");
while($res = mysqli_fetch_array($rst))
if(($res)==TRUE)
echo "
<table class='fixed'>
<td>$res[0]</td><br /><br />
<td>$res[2]</td><br />
<td>➤ $res[12]</td>
";
?>
有没有办法重新创建这个代码干净? 我试图重新创建它,但它没有回应来自sql
的值:
$rst=mysqli_query($link, "SELECT * FROM flux_receptie WHERE status_procesare ='PRELUAT' AND status_solutionare ='' ORDER BY ora_preluare DESC LIMIT 5");
while($res = mysqli_fetch_array($rst))
if(($res)==TRUE)
?>
<table class='fixed'>
<td><? print $res[0]; ?></td><br /><br />
<td><? print $res[2]; ?></td><br />
<td>➤ <? print $res[12]; ?></td>
有人可以建议我如何制作干净的代码吗?
你的编码有很多错误。 首先改进它,然后构建应用程序。
<table class='fixed'>
<?php
$rst = mysqli_query($link, "SELECT *
FROM flux_receptie
WHERE status_procesare = 'PRELUAT'
AND status_solutionare = ''
ORDER BY ora_preluare DESC
LIMIT 5");
while($res = mysqli_fetch_array($rst, MYSQLI_ASSOC)) {
?>
<tr>
<td><?php echo $res['database_field_one']; ?></td>
<td><?php echo $res['database_field_two']; ?></td>
<td>➤ <?php echo $res['database_field_three']; ?></td>
</tr>
<?php
}
?>
</table>
列出其中一些
mysqli_fetch_array
缺少参数- 不使用
if(($res)==TRUE)
,了解empty()
while
循环后没有花括号{}
<table class='fixed'/>
应该定义 while 循环的顶部。- 我们从不在表中使用
<br />
- 所有
<td>
都应该在<tr>
和 .- 我们从不指向这样的数据
$res[0]
。
输入这个代码
<?php
$rst=mysqli_query(
$link,
"SELECT * FROM flux_receptie WHERE status_procesare ='PRELUAT' AND status_solutionare ='' ORDER BY ora_preluare DESC LIMIT 5"
);
while($res = mysqli_fetch_array($rst)) {
?>
<table class='fixed'>
<td><?php echo $res[0];?></td><br /><br />
<td><?php echo $res[2];?></td><br />
<td>➤ <?php echo $res[12];?> </td>
</table>
<table class='fixed'>
<?php
$rst = mysqli_query($link, "SELECT *
FROM flux_receptie
WHERE status_procesare = 'PRELUAT'
AND status_solutionare = ''
ORDER BY ora_preluare DESC
LIMIT 5");
while($res = mysqli_fetch_array($rst, MYSQLI_ASSOC)) {
?>
<tr>
<td><?php echo $res['fieldname']; ?></td>
<td><?php echo $res['fieldname2']; ?></td>
<td>➤ <?php echo $res['fieldanme3']; ?></td>
</tr>
<?php
}
?>
</table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.