php - 如何在 PHP 中以字符串形式显示数据库中表的内容?

标签 php mysql html-table

这是我试过的。我以表格的形式显示了结果。我希望结果显示为单行,我可以为其应用选取框。我的导师建议将结果放在一个字符串中,然后显示它们。如何实现?

<?    
mysql_connect("localhost", "root", "qwerty") or die(mysql_error());
mysql_select_db("ups_status") or die(mysql_error());

$value = $_POST[input] ;
$order3 = "SELECT * FROM ups_status1 WHERE (ups_temp > 45)and(Ipaddress LIKE '%".$value."%')";
$results3 = mysql_query($order3) or die('Invalid query: ' .mysql_error());

echo"<div id=ups_sty ><h4>Temperature Status</h4></div>";
if(mysql_num_rows($results3)>0)
{
echo "<div id=ups_sty2><marquee behavior=alternate>Temperature of one or more UPS is high!!</marquee></div>";   
echo "<table border='0' width='200' cellpadding='2' cellspacing='2'>";

echo "<tr align='center' bgcolor='#002C40' style='color:#FFF'>
<td height='35px' width='500px'>IP ADDRESS</td> 
</tr>"; 

  while($result5 = mysql_fetch_row($results3))
 {
   echo "<tr align='center' bgcolor='#f0f0f0'>
<td height='25px'>".$result5[1]."</td>
</tr>" ;
 }
echo "</table>";
/*Instead of displaying them in a tabular way, I want to display them consecutively...*/
?>

最佳答案

使用这个(完整代码)

?>
<div id=ups_sty2>
    <marquee behavior=alternate>Temperature of one or more UPS is high!!</marquee>
</div> 

    <?php
        while ($raw = mysql_fetch_array($results3))
            {
                <p><?php echo $raw["tbale_field name1"]; ?></p>
            }
    ?>

关于php - 如何在 PHP 中以字符串形式显示数据库中表的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30993679/

相关文章:

php - 使用 php 纯文本和 html 发送电子邮件

php - 当某些标题比其他标题长并且需要换行时,使所有标题元素具有相同的高度

php - fatal error : Call to undefined function mysqli_connect()

MySQL DAYOFWEEK() - 我的一周从星期一开始

php - 计算 Eloquent 中两条记录之间的值差异

html - css:表格可水平和垂直滚动,带有固定标题

php select 查询按日期汇总已售商品的数量

php - MySQL/PHP 错误 : Input a value with an apostrophe ( ' )

css - 单元格填充在 Gmail 中准确,但在 Microsoft Outlook 中不准确

html - 如何在html表格的两行之间换行或空格