Share Pastebin
Guest
Public paste!

Gigs

By: a guest | Mar 20th, 2010 | Syntax: PHP | Size: 2.44 KB | Hits: 78 | Expires: Never
Copy text to clipboard
  1. gigs.php
  2.  
  3. <title>Gigs</title>
  4. <?php
  5.  
  6. print "<link rel='stylesheet' type='text/css' href='css/viewall.css' />";
  7. print "<script src='scripts/scotfolk.js'></script>";
  8. mysql_connect('localhost','root','3107') or die(mysql_error());
  9. mysql_select_db('a09002039') or die(mysql_error());
  10.  
  11. $findday = mysql_query("SELECT DISTINCT day FROM gig");
  12. $findtown = mysql_query("SELECT DISTINCT town FROM gig");
  13. $findband = mysql_query("SELECT DISTINCT band FROM gig");
  14. $findvenue = mysql_query("SELECT DISTINCT venue FROM gig");
  15.  
  16. if ($_GET['sday'] == null) { $sday = '%'; } else { $sday = $_GET['sday']; }
  17. if ($_GET['stown'] == null) { $stown = '%'; } else { $stown = $_GET['stown']; }
  18. if ($_GET['sband'] == null) { $sband = '%'; } else { $sband = $_GET['sband']; }
  19. if ($_GET['svenue'] == null) { $svenue = '%'; } else { $svenue = $_GET['svenue']; }
  20.  
  21.  
  22.  
  23. print "<div id='display'>Gigs by <select name='sband'><option selected value='%'>any band</option>";
  24. while ($bands = mysql_fetch_array($findband)){
  25. print "<option value='%$bands[0]%'>$bands[0]</option>";
  26. }
  27. print "</select> on <select name='sday'><option selected value='%'>any day</option>";
  28. while ($days = mysql_fetch_array($findday)) {
  29. print "<option value='%$days[0]%'>day $days[0]</option>";
  30. }
  31. print "</select> of the week in <select name='stown'><option selected value='%'>any town</option>";
  32. while ($towns = mysql_fetch_array($findtown)) {
  33. print "<option value='%$towns[0]%'>$towns[0]</option>";
  34. }
  35. print "</select> in the venue <select name = 'svenue'><option selected value='%'>any</option>";
  36. while ($venues = mysql_fetch_array($findvenue)) {
  37. print "<option value='%$venues[0]%'>$venues[0]</option>";
  38. }
  39. print "</select><button type='button' onclick='showGigs()'>Go</button>";
  40.  
  41. $query = sprintf("SELECT id,day,town,band,venue,details FROM gig WHERE day LIKE '%s' AND town LIKE '%s' AND band LIKE '%s' AND venue LIKE '%s'", mysql_real_escape_string($sday), mysql_real_escape_string($stown), mysql_real_escape_string($sband), mysql_real_escape_string($svenue));
  42. $result = mysql_query($query) or die(mysql_error()); ;
  43.  
  44. print "<table border='1'><tr><th>ID</th><th>Day of Week</th><th>City</th><th>Band</th><th>Venue</th><th>Details</th><th>Promotional</th></tr>";
  45. while ($a = mysql_fetch_array($result)){
  46.  print "<tr><td>$a[0]</td><td>$a[1]</td><td>$a[2]</td><td>$a[3]</td><td>$a[4]</td><td>$a[5]</td><td><a href='gigdetail.php?id=$a[0]' target='_blank'>Poster</a></td></tr>";
  47. }
  48. print "</table></div>";
  49.  
  50. ?>