我需要一些帮助显示多个mysql记录的日期值是相同的。
例子:
==========================
31 July
Record 1
2 August
Record 2
Record 3
5 August
Record 4
Record 5
6 August
Record 6
==========================
mysql记录示例数据:
nid | neventName | nstartDate
----+------------+-----------
| 1 | Record 1 | 2018-07-31
| 2 | Record 2 | 2018-08-02
| 3 | Record 3 | 2018-08-02
| 4 | Record 4 | 2018-08-05
| 5 | Record 5 | 2018-08-05
| 6 | Record 6 | 2018-08-08
我的代码如下:
<?php
//DATE VALUES
date_default_timezone_set('Asia/Dubai');
$currentDate = date("Y-m-d");
$startDate = $rs_EventsVenuesListing_rows['nstartDate'];
$date = date_create($startDate);
//CREATE SQL STATEMENT
$sql_EventsVenuesListing = "SELECT * FROM tblvenueListingsEvents WHERE $currentDate <= nstartDate ORDER BY nstartDate ASC";
//$sql_EventsVenuesListing = "SELECT DISTINCT nstartDate FROM tblvenueListingsEvents WHERE $currentDate <= nstartDate ORDER BY nstartDate ASC";
//CONNECT TO MYSQL SERVER
require('inc-conn.php');
//EXECUTE SQL STATEMENT
$rs_EventsVenuesListing = mysqli_query($vconn, $sql_EventsVenuesListing);
//CREATE AN ASSOCIATIVE ARRAY
//$rs_EventsVenuesListing_rows = mysqli_fetch_assoc($rs_EventsVenuesListing);
?>
<?php
echo "<table border = 1px>";
while ($rs_EventsVenuesListing_rows = mysqli_fetch_assoc($rs_EventsVenuesListing)) {
// printing table row
// ##### DISPLAY ALL DATES USING START DATE FROM EVENTS #####
echo'<tr>';
echo '<td>'.$rs_EventsVenuesListing_rows['nstartDate'].'</td>';
echo'</tr>'; // closing table row
// ##### DISPLAY ALL EVENTS THAT HAS THE SAME START DATE #####
if ($startDate = $startDate) {
echo'<tr>';
echo '<td>'.$rs_EventsVenuesListing_rows['neventName'].'</td>';
echo'</tr>'; // closing table row
}
echo'<tr>';
echo '<td><br></td>';
echo'</tr>'; // closing table row
}
echo '</table>';
?>
<!-- ######################## DISPLAY DATES ######################## -->
您的协助将不胜感激。
当做,
丹麦人
1条答案
按热度按时间ryoqjall1#
下面是一个简单的片段,说明这样一个结构
作品:
此代码不用于复制和粘贴。它只能说明背后的逻辑。