Advertisement
Guest User

Untitled

a guest
Jul 13th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. #!/usr/bin/ruby
  2. require "cgi"
  3. require "mysql"
  4.  
  5. #DB Config
  6. DB_Host = "127.0.0.1"
  7. DB_User = "root"
  8. DB_Pass = "pass"
  9. DB_Table = "ruby"
  10.  
  11. Day_Of_Week = Time.now.strftime("%A")
  12.  
  13.  
  14.  
  15. con = Mysql.new(DB_Host, DB_User, DB_Pass, DB_Table)
  16.  
  17.  
  18. cgi = CGI.new('html4')
  19. rs = con.query("SELECT * FROM specials WHERE day='#{Day_Of_Week}'")
  20. n_rows = rs.num_rows
  21.  
  22.  
  23. cgi.out{
  24. CGI.pretty(
  25. cgi.html{
  26. cgi.head{ "\n"+cgi.title{"This Is a Test"} } +
  27. cgi.body{ "\n"+
  28. cgi.table
  29. n_rows.times do
  30. mah_string = ''
  31. mah_string += rs.fetch_row.join("\s ")
  32. puts mah_string# too much here. s
  33. end
  34. }
  35. }
  36. )
  37. }
  38.  
  39.  
  40. -------------------yields this------------------
  41. 76 Mura Saturday Special not updated
  42. 77 Sparians Saturday Special not updated
  43. 78 The Oxford Saturday $4 Vodka Drinks $5 Fireball $6 Vodka Red Bull
  44. 79 Sono Saturday Special not updated
  45. 80 Isaac Hunter Saturday Special not updated
  46. 81 Cameron Bar and Grill Saturday Special not updated
  47. 82 Taste Saturday Special not updated
  48. 83 Hibernian Saturday Special not updated
  49. 84 Backyard Bistro Saturday $2 Bud, Bud Light, Bud Light Lime, and Platinum Bottles, $3 Jose Cuervo, $5 Patron, Avion and Tres Gen
  50. 85 East Village Saturday $3 Coronas$3 Pints of NC Craft Beers$5 Flavored Mojitos$5 Vodka Bombs(Any Flavor)$3 Glasses of White Zinf
  51. 86 Capital Club Saturday Special not updated
  52. 87 Rukus Raleigh Saturday Special not updated
  53. 88 The Pickled Onion Saturday Bud Light Drafts$2.50Harpoon SeasonalDrafts$3.50Bell`s TwoHearted Drafts$3.50Sangria$4.00Royal Flush
  54. 89 Nappertandys Saturday $2.25 Natural Light Bottles$5 Crown, Crown Maple, Crown Blackbr />
  55. 90 Saints and Scholars Saturday
  56. Content-Type: text/html
  57. Content-Length: 202
  58.  
  59. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  60. <HTML>
  61. <HEAD>
  62.  
  63. <TITLE>
  64. This Is a Test
  65. </TITLE>
  66. </HEAD>
  67. <BODY>
  68. 15
  69. </BODY>
  70. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement