Help with Database Query...

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 4
Reputation: ncognito66 is an unknown quantity at this point 
Solved Threads: 0
ncognito66 ncognito66 is offline Offline
Newbie Poster

Help with Database Query...

 
0
  #1
Jul 17th, 2008
Sorry, I posted this in the wrong area (I'm using MySQL)





Hello all:

I'm currently building a website for a radio station and I want to setup a programming lineup. The fields I'm using are:

ID
Title
Dayofweek (Show Day)
Timeslot (Show Time)
AMPM (AM or PM)
Description
Name (Host Name)
Bio (Host Bio)
Photo (Host Photo)

I set these all up as TEXT as I wasn't sure how to do it correctly.

I want to be able to make a schedule listing the shows by Day of Week and then by Time, and I also want to make a box showing the current program on the air.

Any ideas for a newbie????

Thanks all!

Alan
Last edited by ncognito66; Jul 17th, 2008 at 1:14 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 143
Reputation: cutepinkbunnies is an unknown quantity at this point 
Solved Threads: 8
cutepinkbunnies's Avatar
cutepinkbunnies cutepinkbunnies is offline Offline
Junior Poster

Re: Help with Database Query...

 
0
  #2
Jul 22nd, 2008
I'd suggest using a view or a stored procedure. The syntax would be something like the following.

  1. SELECT DAYOFWEEK, MAX(Timeslot) as 'Timeslot', MAX(AM/PM) as 'AM/PM', MAX(Description) as 'Description', MAX(Name) as 'Name', MAX(BIO) as 'Bio', MAX(Photo) as 'Photo'
  2. FROM <TABLENAME>
  3. GROUP BY DAYOFWEEK
  4. ORDER BY DAYOFWEEK, MAX(Timeslot)
Last edited by peter_budo; Jul 23rd, 2008 at 8:25 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 4
Reputation: ncognito66 is an unknown quantity at this point 
Solved Threads: 0
ncognito66 ncognito66 is offline Offline
Newbie Poster

Re: Help with Database Query...

 
0
  #3
Jul 22nd, 2008
Thank you for your help, but I have other problems I guess.

Here's the form I'm using to input my data to the database:

  1. <form action="<?=$PHP_SELF?>" method="post">
  2. <br>
  3. <b>Show Title</b>
  4. <br><input type="text" name="Title" size="50">
  5. <p><b>Day of Week</b>
  6. <br><input type="radio" name="Showday" value="Monday" checked> Monday&nbsp;
  7. <input type="radio" name="Showday" value="Tuesday"> Tuesday&nbsp;
  8. <input type="radio" name="Showday" value="Wednesday"> Wednesday&nbsp;
  9. <input type="radio" name="Showday" value="Thursday"> Thursday&nbsp;
  10. <input type="radio" name="Showday" value="Friday"> Friday&nbsp;
  11. <input type="radio" name="Showday" value="Saturday"> Saturday&nbsp;
  12. <input type="radio" name="Showday" value="Sunday"> Sunday
  13. <p><b>Show Date (2008-07-05)</b>
  14. <br><input type="text" name="Showdate" value="0000-00-00" size="50">
  15. <p><b>Show Time</b>
  16. <br><SELECT NAME="Timeslot">
  17. <option>01:00
  18. <option>01:15
  19. <option>01:30
  20. <option>01:45
  21. <option>02:00
  22. <option>02:15
  23. <option>02:30
  24. <option>02:45
  25. <option>03:00
  26. <option>03:15
  27. <option>03:30
  28. <option>03:45
  29. <option>04:00
  30. <option>04:15
  31. <option>04:30
  32. <option>04:45
  33. <option>05:00
  34. <option>05:15
  35. <option>05:30
  36. <option>05:45
  37. <option>06:00
  38. <option>06:15
  39. <option>06:30
  40. <option>06:45
  41. <option>07:00
  42. <option>07:15
  43. <option>07:30
  44. <option>07:45
  45. <option>08:00
  46. <option>08:15
  47. <option>08:30
  48. <option>08:45
  49. <option>09:00
  50. <option>09:15
  51. <option>09:30
  52. <option>09:45
  53. <option>10:00
  54. <option>10:15
  55. <option>10:30
  56. <option>10:45
  57. <option>11:00
  58. <option>11:15
  59. <option>11:30
  60. <option>11:45
  61. <option>12:00
  62. <option>12:15
  63. <option>12:30
  64. <option>12:45
  65. </SELECT>
  66. <p><b>AM/PM</b>
  67. <br><SELECT NAME="AMPM">
  68. <option>AM
  69. <option>PM
  70. </SELECT>
  71. <p><b>Show Duration</b>
  72. <br><input type="text" name="Duration" value="0:00" size="50">
  73. <p><b>Show Topic (Brief few word description)</b>
  74. <br><input type="text" name="Topic" size="50">
  75. <p><b>Show Description (Full length description)</b>
  76. <br><textarea wrap="virtual" cols="50" rows="12" name="Description"></textarea>
  77. <p><b>Host Name</b>
  78. <br><input type="text" name="Name" size="50">
  79. <p><b>Host Bio</b>
  80. <br><textarea wrap="virtual" cols="50" rows="12" name="Bio"></textarea>
  81. <p><b>Host Photo Filename</b>
  82. <br><input type="text" name="Photo" size="50">
  83. <br>
  84. <br>
  85. <br><input type="submit" name="submitshow" value="Submit Show"></form>

I insert the data with the following:

  1. $sql = "INSERT INTO shows SET
  2. Title='$Title',
  3. Timeslot='$Timeslot',
  4. AMPM='$AMPM',
  5. Showday='$Showday',
  6. Showinfo='$Showinfo',
  7. Showdate='$Showdate',
  8. Duration='$Duration',
  9. Topic='$Topic',
  10. Description='$Description',
  11. Name='$Name',
  12. Bio='$Bio',
  13. Photo='$Photo'";

Notice I have separate fields for Showday (Day of Week), Showdate (Actual Date), Showtime (Time of show),and AM/PM. I guess my first problem is:

How do I merge those fields into a Date/Time form that MYSQL will recognize?

I originally had all the columns as TEXT which worked except 12:00 Noon came after 11:00PM, so I changed the Showdate column to DATE and Timeslot to TIME, but I still have the AM/PM problem.

Once I get the info inputted into MYSQL in the proper format, then I need to pull up schedules by week, day, and "Currently on the Air". But I need to know what I'm doing wrong with my data input first.

Thank you so much!!

Alan
<EMAIL SNIPPED>
Last edited by peter_budo; Jul 23rd, 2008 at 8:27 pm. Reason: Keep It On Site - Do not post asking for an answer to be sent to you via email or PM.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 143
Reputation: cutepinkbunnies is an unknown quantity at this point 
Solved Threads: 8
cutepinkbunnies's Avatar
cutepinkbunnies cutepinkbunnies is offline Offline
Junior Poster

Re: Help with Database Query...

 
0
  #4
Jul 23rd, 2008
It looks like your SQL syntax is incorrect. Read up on INSERT syntax here.

Please keep us updated on your progress/trial & error.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 296
Reputation: tesuji is on a distinguished road 
Solved Threads: 42
tesuji tesuji is offline Offline
Posting Whiz in Training

Re: Help with Database Query...

 
0
  #5
Jul 25th, 2008
Hello,

you may have a look at DATE_FORMAT(date, format), especially specifier %p to convert date and time values.

krs,
tesu
Information is moving—you know, nightly news is one way, of course, but it's also moving through the blogosphere and through the Internets. I promise you I will listen to what has been said here, even though I wasn't here. Ann and I will carry out this equivocal message to the world. I'm the master of low expectations.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC