更新的 PHP
似乎与尖括号有关...
我第一次编写自己的 PHP 和 SQL,但遇到了一些麻烦,所以还没有插入 HTML。我想我没有正确地逃避某些事情,或者我的格式差了几英里……或者真的很简单。
我基本上是在尝试获取一个有效的事件列表,以及这里的许多帖子,只是无法将它们全部放在一起以获得结果。
所以我在寻找
YEAR
MONTH
EVENT
MONTH
EVENT
EVENT
YEAR etc
我的 HTML 看起来像这样......
<div id="year">
<p class="vert">YEAR</p>
<div id="month">
<h1>MONTH</h1>
<div class="event">
<p>DATE START - DATEEND IF DIFFERENT/AVAILABLE</p>
<div class="eventmain">
<img class="flag" src="./img/defaultflag.png">
<img class="open" src="./img/plus.png">
<img class="close" src="./img/minus.png">
<h2> Event Name </h2>
<div class="eventdetails">
<p>FORMAT</p>
<p>INFO</p>
<p>CONTACT</p>
<p>EMAIL</p>
<p>WEBSITE</p>
</div> <!-- close div event details -->
</div> <!-- close div event main -->
</div> <!-- close div event -->
</div> <!-- close div month -->
</div> <!--close div year-->
使用 DB 辩论日历中的以下数据库字段,表事件 event_name,event_startdate,event_enddate,event_flag,event_format,event_info,event_contactinfo,event_email,event_website,event_reg
我有以下 PHP
<?php
$server = "localhost:8889";
$user = "root";
$passwd = "root";
$db_name = "debate_calendar";
$table_name = "events";
$conn = mysql_connect($server, $user, $passwd) or die("Couldn't connect to SQL Server on $server");
mysql_select_db($db_name, $conn);
if (!$conn)
{
exit("Failed to Connect to $dbConnection");
}
else
{
echo "Database Connected";
}
$query = "SELECT * FROM `debate_calendar`.`events` WHERE event_date > NOW() ORDER BY event_date DESC";
$result = mysql_query( $query );
$current_month = '';
$current_year = '';
while ($event = mysql_fetch_assoc($result)) {
$year = date('y', $event['event_startdate']);
if($current_year != $year)
{
$current_year = $year;
echo ("<h1>" .$current_year. "</h1>");
}
$month = date('m', $event['event_startdate']);
if($current_month != $month)
{
$current_month = $month;
echo '<h2>' . $current_month . '</h2>';
}
echo '<p>' . $event['event_name'] . '</p>';
}
mysql_close($con);
?>
但它所产生的只是......
NOW() ORDER BY event_date DESC"; $result = mysql_query( $query ); $current_month = ''; $current_year = ''; while ($event = mysql_fetch_assoc($result)) { $year = date('y', $event['event_startdate']); if($current_year != $year) { $current_year = $year; echo ("
" .$current_year. "
"); } $month = date('m', $event['event_startdate']); if($current_month != $month) { $current_month = $month; echo '
' . $current_month . '
'; } echo '
' . $event['event_name'] . '
'; } mysql_close($con); ?>