Is there php code that will do this ...

equalizer

Junior Member
Joined
Jul 20, 2008
Messages
150
Reaction score
64
Can some programmer genius write me some php code for my blog that will fetch a different video from youtube or other leading video servers every time the page loads.
 
do you just want a random video, or from a specific list of videos?
 
If you have a few randoms, you can do (php):
Code:
$random = rand(0,5);
	
	if ($random == 0){
		//video 1
	}
	
	if ($random == 1){
		//video 2
	}

etc...

if they coming from a database its pretty much the same, just your query will change basedon the random number. this depends on how your DB structure

PM me if you need help with anything
 
Thank you Eskimo, I will try it and report.
 
you could also scrape a lot of urls, using scrapebox or something similar, then put them into a mysql db, then have php grab a random row from the db.

More efficient and you could have literally millions in there.

Then you could append to that list of urls whenever you wanted, scrape new ones and dump in there, and you could scrape videos that were specifically related to the niche.

I'd post the code but it blocks me because im new.

mysql has a query in select where you do a "select from db order by rand() limit 1" then the resulting output is a random row, without using random number function or having access to the other rows in memory.
 
Last edited:
Back
Top