doutan1637 2017-05-01 21:27
浏览 54

如何在适当的HTML表中显示PHP变量

Hey guys its my first question here I think.

So I'm using MyBB Forum software.

I have a PHP code that fetches some data from a database no issues in there its working properly.

$query = $db->query("SELECT * FROM housing");
while($result = $db->fetch_array($query))
{    
    $housingvar .= "<td>". $result['username']. "</td>";
    $price .= "<td>". $result['Price']. "</td>";
    $city .= "<td>". $result['City']. "</td>";
    $tax .= "<td>". $result['Tax']. "</td>"; 
    $adrz .= "<td>". $result['Adress']. "</td>";
}

This is the code. I'm using. These variables are then plugged in an HTML table on the forum but everything is in the same column and I dont know how to make a new row for every data. I'm sure this is possible but dont know how.

I cant use echo in my PHP code either. Since I'm using these variables in a pure HTML template.

<tr>
    {$housingvar}
         {$price} 
          {$city}
            {$adrz}
            {$tax}
    </tr>
  • 写回答

2条回答 默认 最新

  • dongqiang8683 2017-05-01 21:31
    关注

    To create a new row in an HTML table, you use the <tr> tag. I would try the following:

    echo "<tr>";
       $price = $result['Price'];
       echo "<td> $price </td>";
        //other code here
    echo "</tr>";
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)