如何检索数据数据库表在同一行

时间:2017-12-09 14:58:02

标签: php mysql pivot

我希望它以这种格式显示。

format

数据库中的表

table

但确实如此出现。

line

但我要展示的是连续的信息。

我使用THAIS CODE

<?php


$bdaytime = $_GET['bdaytime'];
$bdaytime2 = $_GET['bdaytime2'];

include "connect_db.php";
$sql = "SELECT
*

FROM
wp_cf7_data, wp_cf7_data_entry

WHERE
wp_cf7_data.id=wp_cf7_data_entry.data_id and cf7_id = 1470 AND name in ('your-name','your-email') and  wp_cf7_data.created  BETWEEN '$bdaytime' and '$bdaytime2' ORDER BY data_id ASC ";



$query = mysqli_query($conn, $sql);
$num=mysqli_num_rows($query);

?>

<table width="600" border="1">

  <tr>

    <th width="91"> <div align="center">id </div></th>
    <th width="98"> <div align="center">date </div></th>
<th width="59"> <div align="center">email</div></th>
    <th width="59"> <div align="center">name </div></th>

  </tr>
<?php
while($result=mysqli_fetch_array($query,MYSQLI_ASSOC))
{
?>
  <tr>
    <td><div align="center"><?php echo $result["data_id"];?></div></td>
    <td><?php echo $result["created"];?></td>
    <td align="right"><?php echo $result["name"];?></td>
    <td align="right"><?php echo $result["value"];?></td>

  </tr>
  <?php echo $result["numberOfRows"];


?>
<?php
}
?>

抱歉,我不是很好的英语

谢谢

0 个答案:

没有答案