Go Back  DVD Talk Forum > General Discussions > Tech Talk
Reload this Page >

javascript help...or maybe php?

Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

javascript help...or maybe php?

Old 02-07-03, 12:46 PM
  #1  
DVD Talk Gold Edition
Thread Starter
 
Join Date: Aug 1999
Location: Chicago, IL
Posts: 2,538
Likes: 0
Received 0 Likes on 0 Posts
javascript help...or maybe php?

Hi all,
What I'm trying to do is this:

Have a section on a web page to change information, and a photo, as the time changes. You see this all the time on radio stations, such as www.wlsam.com with the On The Air area.
For example, when it's 8 am, the area should say something like Now Playing: Elvis Presley (img)

Then at say 10 it'll be The Beatles.
I hope I made some sense....and if I did, any ideas?

Neitzl
Old 02-07-03, 12:50 PM
  #2  
DVD Talk Gold Edition
 
Join Date: Dec 1999
Posts: 2,708
Likes: 0
Received 0 Likes on 0 Posts
You could probably use either javascript or some kind of server side script to accomplish this. If you use javascript, you'll have to create an array (probably the easiest way) with all the different images/text to show, and then check what time it is when the page is loaded and swap out the images depending on what time of day it is. If you want to pull it from a dB (and I would wholeheartedly recommend this way as I think it's much easier ), use PHP. You could check what time it is, and show the different image based upon time of day, and set up a table with different info for different times of the day.

Edited to add...
From the look of their page, they seem to be using server side code to display the image based upon time of day.
Old 02-07-03, 01:05 PM
  #3  
Mod Emeritus
 
Gallant Pig's Avatar
 
Join Date: Aug 1999
Posts: 15,325
Likes: 0
Received 0 Likes on 0 Posts
Go with server side scripting using ASP and access DB. Lampei, they have ASP extensions on their various pages so you're definitely right.
Old 02-07-03, 01:12 PM
  #4  
Mod Emeritus
 
Gallant Pig's Avatar
 
Join Date: Aug 1999
Posts: 15,325
Likes: 0
Received 0 Likes on 0 Posts
You're probably better off using VBScript than JScript also. There's a lot more books and writing about VBScript + ASP + DB than JScript from what I've seen.
Old 02-07-03, 01:26 PM
  #5  
DVD Talk Gold Edition
Thread Starter
 
Join Date: Aug 1999
Location: Chicago, IL
Posts: 2,538
Likes: 0
Received 0 Likes on 0 Posts
Hey guys,
thanks for the suggestions. I know that there is some javascript stuff that will do it, but I know nada about javascript or vbscript. I do know some basic php though, and I want to go that route, but I was hoping there was some script already out there that someone knew that I could just copy and fit to my needs.
I'll try the php/mysql thing though on my own. If/when I can't figure it out, I'll be back

Thanks again

Neitzl
Old 02-07-03, 02:01 PM
  #6  
DVD Talk Gold Edition
 
Join Date: Dec 1999
Posts: 2,708
Likes: 0
Received 0 Likes on 0 Posts
The script should be pretty easy...

create a table with integer times and show info, such as
Time Show
1 Bush
2 Beer
3 Candy

and name all of your images based upon the time they're showing

Then query dB for this info.
Then loop

if showInfo.Time = Hour(now())
(showInfo.Time).jpg
You're watching showInfo.Show
end if

end loop

Old 02-07-03, 02:50 PM
  #7  
DVD Talk Gold Edition
Thread Starter
 
Join Date: Aug 1999
Location: Chicago, IL
Posts: 2,538
Likes: 0
Received 0 Likes on 0 Posts
Lampei,
Say, thanks for the info/code. I'll try it out in zend and see how it works.
Old 02-07-03, 02:55 PM
  #8  
DVD Talk Gold Edition
 
Join Date: Dec 1999
Posts: 2,708
Likes: 0
Received 0 Likes on 0 Posts
oops, need to edit that code No loop needed. In the SQL query, just add something like

select * from showTimes where ID = '#Hour(Now())#'

If you were going to do something that occurred every ten minutes, you could add 2 extra columns to the table such as hours and minutes. Then you could do this SQL statement

select * from showTimes where ID = '#Hour(Now())#' AND theMinutes = '#Evaluate(Minutes(Now())\10)#'

and reference the image still based upon the ID returned.

This is all in ColdFusion, but could probably be ported to PHP relatively easily

Last edited by Lampei; 02-07-03 at 03:04 PM.

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service - Do Not Sell My Personal Information

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.