Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 7th, 2012  |  syntax: PHP  |  size: 2.53 KB  |  views: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <html>
  2. <style>
  3. html{
  4. font-family: arial;
  5. }
  6. </style>
  7. <h1>Local Events</h1>
  8. <hr>
  9. <br>
  10. <?php
  11. //mysql connection
  12. mysql_connect('localhost', 'root', '') OR DIE ("Unable to connect to database! Please try again later.");
  13.  
  14. //selecting the table
  15. mysql_select_db('local');
  16.  
  17. //query
  18. $query = mysql_query("SELECT *, CONCAT(DATE_FORMAT(date_start, '%M %d'),(IF(date_start = date_end,'',CONCAT(' - ', DAY(date_end)))))
  19. newDate FROM events3 WHERE date_end >= CURDATE() ORDER BY date_start LIMIT 5");
  20.  
  21. //CONCAT(DATE_FORMAT(date_start, '%M %d'), ' - ', DAY(date_end)) newDate and in your php $dateSched = $rows['newDate']; echo "<b>Date Start:</b>&nbsp;&nbsp;&nbsp;"; echo $dateSched;
  22.  
  23. //SELECT * FROM events3 WHERE date_end >= CURDATE() ORDER BY date_start LIMIT 5; ::BEST ONE!!
  24.  
  25. //http://stackoverflow.com/questions/2597098/get-the-last-n-rows-in-the-database-in-order
  26. //SELECT * FROM events ORDER BY date_start DESC LIMIT 5 ::Works but still need to reverse order
  27. //SELECT * FROM events ORDER BY id DESC LIMIT 5;
  28. //SELECT * FROM events ORDER BY id DESC LIMIT 5;
  29. //WHERE year = '2012'
  30.  
  31. //fetch results
  32.        
  33.         WHILE($rows= mysql_fetch_array($query)):
  34.                
  35.                 $id =                   $rows['id'];   
  36.                 $title =                $rows['title'];
  37.                 $admission =            $rows['admission'];
  38.                        
  39.                 $date_start =       $rows['date_start'];
  40.                 $date_end =             $rows['date_end'];
  41.                 $dateSched =            $rows['newDate'];
  42.                
  43.                 $time_start =           $rows['time_start'];
  44.                 $time_end =             $rows['time_end'];
  45.                
  46.                 $location =             $rows['location'];
  47.                 $description =          $rows['description'];
  48.                 $image =                $rows['image'];
  49.                 $hyperlink =            $rows['hyperlink'];                    
  50. ?>
  51. <?php
  52.         //ID/ Title Display
  53.         //echo "<b>ID:</b>&nbsp;&nbsp;&nbsp;";                                  echo "$id<br>";
  54.         echo "<b>Title:</b>&nbsp;&nbsp;&nbsp;";                                 echo "$title<br>";
  55.         if ($admission == null  ){
  56.                 echo " ";
  57.         }else{
  58.                 echo "<b>Admission:</b> &nbsp;&nbsp;&nbsp";                             echo "$admission<br>"; 
  59.         }
  60.  
  61.         //Date Display
  62.         echo "<b>Date Start:</b>&nbsp;&nbsp;&nbsp;";                   
  63.         echo "$dateSched<br>";
  64.         //echo "$date_start"; echo '&nbsp;-&nbsp';       echo "$date_end<br>";
  65.  
  66.         //Time Display
  67.         echo "<b>Time Frame:</b>&nbsp;&nbsp;&nbsp;";                   
  68.         echo date('g:i a',strtotime($time_start)); echo"&nbsp;-&nbsp;"; echo date('g:i a',strtotime($time_end)); echo"<br>";
  69.         //      echo "$time_start";     echo "&nbsp;-&nbsp;";           echo "$time_end<br>";
  70.        
  71.        
  72.         echo "<b>Location:</b>&nbsp;&nbsp;&nbsp;";              echo "$location<br>";
  73.         echo "<b>Description:</b>&nbsp;&nbsp;&nbsp;";   echo "$description<br><hr><br>";
  74.        
  75.        
  76.        
  77.         endwhile;
  78. // SELECT * FROM events ORDER BY id DESC LIMIT 10;
  79. ?>
  80.  
  81. </html>