[GRATIS] Random Youtube V1

Gestart doorSanderc4 reacties16 weergaven

5 berichten · pagina 1 van 1

Sanderc

Lid · Topicstarter

Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

Een 2-tal weken geleden ben ik begonnen met PHP leren, ik had toen al een paar dingen gemaakt. Waaronder de Random Youtube V1. Het stelt nog niet veel voor, maar ik wil het toch met jullie delen.

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]# Copyright Sander C. 2012 #
# Niet cleinmen als uw eigen #

//Hier voeg je handmatig de namen van de code (!!!GENUMMERD!!!). Dus $naam [1] is de naam van $code [1][/COLOR]
[COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]"Gusttavo Lima con Neymar - Balada"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]2[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]"Carly Rea Jepsen - Call My Maybe"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]3[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]"Triggerfinger - I Follow Rivers"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]4[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]"Gers Pardoel ft. Sef - Bagagedrager"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]5[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]"DJ Fresh ft. Rita Ora - Hot Right Now"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]6[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]" Jason Derulo - Skys the limit"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #FF8000]// Hier plak je de code van de youtube video in. Dit stuk staat achter de [/COLOR]
[COLOR= #0000BB]$code[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]"SYhF56heGxw"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$code[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]2[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]"fWNaR-rxAic"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$code[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]3[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]"fzWQV5OiQQQ"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$code[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]4[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]"MZRw9NiVUuM"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$code[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]5[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]"5_4CDt4To9A"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$code[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]6[/COLOR][COLOR= #007700]] =[/COLOR][COLOR= #DD0000]"MYGjxZh0W7U"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #FF8000]// Alles tellen[/COLOR]
[COLOR= #0000BB]$codes[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/count"]count[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$code[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$naams[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/count"]count[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$naam[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$random[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$codes[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$videototaal[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$code[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//Het tellen van het totaal van alle videos. [/COLOR]
?>
<html>
<head>
<title>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$naam[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$random[/COLOR][COLOR= #007700]];[/COLOR] ?></title>
<meta http-equiv="refresh" content="360"> <!-- De pagina refresht automatish na 6 minuten. -->
<style type="text/css">
//* CSS van de info blok *//
.info{
border:1px solid #444444;
text-align:center;
width:50%;
margin-right:auto;
margin-left:auto;
background-image:url(http://icons.iconarchive.com/icons/deleket/plastic-mini/32/Button-Reload-icon.png);
background-repeat:no-repeat;
background-position:right top;
}
</style>
</head>
<body style=" font-family:Arial;">
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]//Checken of het aantal codes klopt bij het aantal namen[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$codes[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #0000BB]$naams[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]De namen bij de codes klopppen niet.[/COLOR][COLOR= #007700];
 }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="info" onclick="javascript:location.reload(true)">Nu speelt: <strong>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$naam[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$random[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</strong><br/>
[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$videototaal[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] videos - Copyright Sander Corens 2012
</div><br/>
<center><embed src="http://www.youtube.com/v/[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$code[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$random[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="1200" height="720"></embed></center>
<br/>[/COLOR][COLOR= #007700];
}[/COLOR]
?>
</body>
</html>


Door de examens kan ik niet verder PHP leren, maar als ik er binnenkort verder aan kan doen. Maak ik het uitgebreider met een admin zodat je niets meer in het script zelf moet aanpassen, met de database dus. Dat zal de v2 worden.

Demo: http://sander.s3.one2xs.com/PHP/musicV1

Tips of verbeteringen zijn altijd welkom.
Reacties natuurlijk ook biggrin
Sander
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Gebruik de youtube ids als key, en titel als value i.p.v twee losse arrays.....
0
Sanderc

Lid · Topicstarter

Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Keys, arrays - Nog niet geleerd jammer genoeg sadley
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Basis kennis arrays...

$song[ABCD123`] = Pietje Puk - Waar is mijn driewieler`;

En zie array_rand()
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
naam => URL

En je kan er beter random linkpartner van maken ofzo. Word meer gebruikt. Of gwn random dingen.

toevoeging op 16 mei 2012, 21:31:34:
En kijken of filmpje bestaat zou ook tof zijn.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren