Advertisement
Guest User

Untitled

a guest
Dec 6th, 2012
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1.  <?php
  2. //mysql connection
  3. mysql_connect('localhost', 'root', '') OR DIE ("Unable to connect to database! Please try again later.");
  4.  
  5. //selecting the table
  6. mysql_select_db('local');
  7.  
  8. //query
  9. $query = mysql_query("SELECT * FROM events3 WHERE date_end >= CURDATE() ORDER BY date_start LIMIT 5;");
  10.  
  11. //http://stackoverflow.com/questions/2597098/get-the-last-n-rows-in-the-database-in-order
  12. //SELECT * FROM events ORDER BY date_start DESC LIMIT 5 ::Works but still need to reverse order
  13. //SELECT * FROM events ORDER BY id DESC LIMIT 5;
  14. //SELECT * FROM events ORDER BY id DESC LIMIT 5;
  15. //WHERE year = '2012'
  16.  
  17. //fetch results
  18.    
  19.     WHILE($rows= mysql_fetch_array($query)):
  20.        
  21.         $id =               $rows['id'];   
  22.         $title =            $rows['title'];
  23.            
  24.         $date_start =       $rows['date_start'];
  25.         $date_end =         $rows['date_end'];
  26.        
  27.         $time_start =       $rows['time_start'];
  28.         $time_end =         $rows['time_end'];
  29.        
  30.         $location =         $rows['location'];
  31.         $description =      $rows['description'];
  32.         $image =            $rows['image'];
  33.         $hyperlink =        $rows['hyperlink'];        
  34. ?>
  35. <html>
  36. <style>
  37. html{
  38. font-family: arial;
  39. }
  40. </style>
  41. <?php
  42.     echo "<b>ID:</b>&nbsp;&nbsp;&nbsp;";                    echo "$id<br>";
  43.     echo "<b>Title:</b>&nbsp;&nbsp;&nbsp;";                 echo "$title<br>";
  44.  
  45.     echo "<b>Date Start:</b>&nbsp;&nbsp;&nbsp;";           
  46.     echo "$date_start"; echo '&nbsp;-&nbsp';     echo "$date_end<br>";
  47.  
  48.     echo "<b>Time Frame:</b>&nbsp;&nbsp;&nbsp;";           
  49.     echo "$time_start";     echo "&nbsp;-&nbsp;";       echo "$time_end<br>";
  50.    
  51.    
  52.     echo "<b>Location:</b>&nbsp;&nbsp;&nbsp;";      echo "$location<br>";
  53.     echo "<b>Description:</b>&nbsp;&nbsp;&nbsp;";   echo "$description<br><br><br>";
  54.    
  55.     if ($date_start == $date_end)   {
  56.         echo '$date_start';
  57.     }else{
  58.    
  59.     }
  60.    
  61.     endwhile;
  62. // SELECT * FROM events ORDER BY id DESC LIMIT 10;
  63. ?>
  64.  
  65. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement