【问题标题】:How to display the contents of a table in a database in form of string in PHP?如何在 PHP 中以字符串的形式显示数据库中表的内容?
【发布时间】:2015-09-08 17:09:31
【问题描述】:

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

<?    
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...*/
?>

【问题讨论】:

    标签: php mysql html-table


    【解决方案1】:

    使用这个(完整代码)

    ?>
    <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>
                }
        ?>
    

    【讨论】:

    • 结果仍然以表格的形式出现。我想在同一行显示结果。 :(
    • 同一行是什么意思??我无法理解。告诉我你到底需要什么
    • 你能附上你的输出图片吗
    • 在显示结果时,所有值都应该连续出现,就像水平的一行,而不是表格形式。现在它以单列形式出现。
    • 所以你不需要表格,你需要单行输出??
    猜你喜欢
    • 2012-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多