Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <style>
- html{
- font-family: arial;
- }
- </style>
- <h1>Local Events</h1>
- <hr>
- <br>
- <?php
- //mysql connection
- mysql_connect('localhost', 'root', '') OR DIE ("Unable to connect to database! Please try again later.");
- //selecting the table
- mysql_select_db('local');
- //query
- $query = mysql_query("SELECT *, CONCAT(DATE_FORMAT(date_start, '%M %d'),(IF(date_start = date_end,'',CONCAT(' - ', DAY(date_end)))))
- newDate FROM events3 WHERE date_end >= CURDATE() ORDER BY date_start LIMIT 5");
- //CONCAT(DATE_FORMAT(date_start, '%M %d'), ' - ', DAY(date_end)) newDate and in your php $dateSched = $rows['newDate']; echo "<b>Date Start:</b> "; echo $dateSched;
- //SELECT * FROM events3 WHERE date_end >= CURDATE() ORDER BY date_start LIMIT 5; ::BEST ONE!!
- //http://stackoverflow.com/questions/2597098/get-the-last-n-rows-in-the-database-in-order
- //SELECT * FROM events ORDER BY date_start DESC LIMIT 5 ::Works but still need to reverse order
- //SELECT * FROM events ORDER BY id DESC LIMIT 5;
- //SELECT * FROM events ORDER BY id DESC LIMIT 5;
- //WHERE year = '2012'
- //fetch results
- WHILE($rows= mysql_fetch_array($query)):
- $id = $rows['id'];
- $title = $rows['title'];
- $admission = $rows['admission'];
- $date_start = $rows['date_start'];
- $date_end = $rows['date_end'];
- $dateSched = $rows['newDate'];
- $time_start = $rows['time_start'];
- $time_end = $rows['time_end'];
- $location = $rows['location'];
- $description = $rows['description'];
- $image = $rows['image'];
- $hyperlink = $rows['hyperlink'];
- ?>
- <?php
- //ID/ Title Display
- //echo "<b>ID:</b> "; echo "$id<br>";
- echo "<b>Title:</b> "; echo "$title<br>";
- if ($admission == null ){
- echo " ";
- }else{
- echo "<b>Admission:</b>  "; echo "$admission<br>";
- }
- //Date Display
- echo "<b>Date Start:</b> ";
- echo "$dateSched<br>";
- //echo "$date_start"; echo ' - '; echo "$date_end<br>";
- //Time Display
- echo "<b>Time Frame:</b> ";
- echo date('g:i a',strtotime($time_start)); echo" - "; echo date('g:i a',strtotime($time_end)); echo"<br>";
- // echo "$time_start"; echo " - "; echo "$time_end<br>";
- echo "<b>Location:</b> "; echo "$location<br>";
- echo "<b>Description:</b> "; echo "$description<br><hr><br>";
- endwhile;
- // SELECT * FROM events ORDER BY id DESC LIMIT 10;
- ?>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement