| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: Dec 2004 Location: Burlington, Vermont
Posts: 1,048
![]() ![]() ![]() | Displaying a random youtube video from a list I've done some searching and can't find this. I'd like a php script that will display a random youtube video picked from a list I create (at a resolution I define). Anyone know of such a thing? |
| |
| | #2 (permalink) |
| NamePros Member Join Date: Mar 2007 Location: Finland
Posts: 29
![]() | If you can't find one, then you will need to make one youself. If you are creating the list yourself, then you can do a SELECT from your database and use rand() with php or Mysql Code: SELECT * FROM table1, table2 WHERE a=b AND c<d -> ORDER BY RAND() LIMIT 1000;
__________________ Regards Jamie Let the might of your compassion arise to bring a quick end to the flowing stream of the blood and tears ..... Please hear my anguished words of truth. |
| |
| | THREAD STARTER #3 (permalink) |
| Senior Member Join Date: Dec 2004 Location: Burlington, Vermont
Posts: 1,048
![]() ![]() ![]() | Thanks for the info. I don't have a database, I was hoping to have a php script that would have the youtube code then pull the video id from a random line of a txt file. Possible? |
| |
| | #4 (permalink) |
| Buy my domains. Join Date: Feb 2006
Posts: 2,796
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | PHP Code: |
| |
| | THREAD STARTER #5 (permalink) | ||||
| Senior Member Join Date: Dec 2004 Location: Burlington, Vermont
Posts: 1,048
![]() ![]() ![]() |
| ||||
| |
| | THREAD STARTER #7 (permalink) | ||||
| Senior Member Join Date: Dec 2004 Location: Burlington, Vermont
Posts: 1,048
![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=324749 it won't let me give you more rep | ||||
| |
| | #8 (permalink) |
| Danltn.com Join Date: May 2007 Location: Danltn.com / Nottingham, UK
Posts: 1,201
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | $line = trim($data[rand(0,count($data))]); <-- It shows whichever video is in position 0. If you changed that variable to 3, then it would show position 3 (i.e. the 4th URL). At least, that's what happeneding on my server. |
| |
| | #9 (permalink) |
| Senior Member Join Date: Mar 2005
Posts: 4,948
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Try array_rand: PHP Code: |
| |
| | THREAD STARTER #10 (permalink) | ||||
| Senior Member Join Date: Dec 2004 Location: Burlington, Vermont
Posts: 1,048
![]() ![]() ![]() |
Thanks, won't let me send rep again, so NPs on the way. | ||||
| |
| | #14 (permalink) | ||||
| Senior Member Join Date: Mar 2005
Posts: 4,948
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
PHP Code: You'd have to: PHP Code: | ||||
| |