nesuxro Posted July 21, 2011 Report Share Posted July 21, 2011 este posibil random youtube?php sau? Quote Link to comment Share on other sites More sharing options...
Moderators Dragos Posted July 21, 2011 Moderators Report Share Posted July 21, 2011 Random video dintr-o baza de date sau lista da. Quote Link to comment Share on other sites More sharing options...
nesuxro Posted July 21, 2011 Author Report Share Posted July 21, 2011 (edited) random youtube in server meu cum se face?? Edited July 21, 2011 by nesuxro Quote Link to comment Share on other sites More sharing options...
Moderators Dragos Posted July 21, 2011 Moderators Report Share Posted July 21, 2011 random youtube in server meu cum se face??<?php//bagam codul clipului in vector$clipuri = array(0 => "wK2U0dYZeQI",1 => "YFK6H_CcuX8",2 => "ctLnNQOVg0E");//alegem la intamplare un cod din vector$rand = $clipuri[rand(0,2)];//afisam clipulecho '<iframe width="425" height="349" src="http://www.youtube.com/embed/' . $rand . '" frameborder="0" allowfullscreen></iframe>';?>Live demo: http://infosource.cz.cc/clipuri.php 1 Quote Link to comment Share on other sites More sharing options...
nesuxro Posted July 21, 2011 Author Report Share Posted July 21, 2011 da foarte frumos.iti multumesc dar nu imi dau seama de unde pina unde sa pun linkurile mele Quote Link to comment Share on other sites More sharing options...
devianc3 Posted July 21, 2011 Report Share Posted July 21, 2011 Clipurile le pui in partea asta://bagam codul clipului in vector$clipuri = array(0 => "wK2U0dYZeQI",1 => "YFK6H_CcuX8",2 => "ctLnNQOVg0E");Ce vezi tu aici, este ce vine in link-ul http://www.youtube.com/watch?v=PoTEnaAI9Fo, de exemplu, dupa v=. Tu doar pui in continuare, de exemplu:/bagam codul clipului in vector$clipuri = array(0 => "wK2U0dYZeQI",1 => "YFK6H_CcuX8",2 => "ctLnNQOVg0E",3 => "PoTEnaAI9Fo");Mai jos, modifici //alegem la intamplare un cod din vector$rand = $clipuri[rand(0,3)]; Practic, linia asta spune sa ia un clip aleatoriu, de la 0 la 3. Daca ai... 1000 de videoclipuri, pui (0,1000). Daca vrei doar... 100 din ele, si alea sunt de la.. 100 la 199, pui (100,199).Cam atat.PS: Bravo lui Synthesis. 1 Quote Link to comment Share on other sites More sharing options...
Moderators Dragos Posted July 21, 2011 Moderators Report Share Posted July 21, 2011 da foarte frumos.iti multumesc dar nu imi dau seama de unde pina unde sa pun linkurile meleSa zicem ca avem linkul asta:http://www.youtube.com/watch?v=aIV2SkMwesUCodul videoclipului este cel de dupa v=, adica aIV2SkMwesU. Asa, il adaugam in vector.<?php$clipuri = array(0 => "wK2U0dYZeQI");?>Ne alegem alt clip, de exemplu:http://www.youtube.com/watch?v=bWXazVhlyxQLa fel, luam codul, si il adaugam in vector.<?php$clipuri = array(0 => "wK2U0dYZeQI",1 => "bWXazVhlyxQ");?>Fii atent la virgula de dupa prima. Virgulele se pun dupa ce declaram o valoare in vector, mai putin la ultima valoare. Sa mai alegem unul, ca asta de mai jos.http://www.youtube.com/watch?v=MMeP8kIUd60Il adaugam in vector, si va iesi..<?php$clipuri = array(0 => "wK2U0dYZeQI",1 => "bWXazVhlyxQ",2 => "MMeP8kIUd60");?>Dupa ceva timp de ales clipurile, scriptul ar putea arata ca urmatorul<?php$clipuri = array(0 => "wK2U0dYZeQI",1 => "bWXazVhlyxQ",2 => "MMeP8kIUd60",3 => "wK2U0dYZeQI",4 => "YFK6H_CcuX8",5 => "ctLnNQOVg0E");?>Pentru a afisa o valoare din vector, folosim sintaxa echo $clipuri[numar]. Spre exemplu, daca vrem sa afisam valoarea wK2U0dYZeQI, vom folosi codul urmator:<?phpecho $clipuri[0];?>Dupa, trecem la alegerea unui clip la intamplare din vector. Pentru asta vom folosi functia rand(start, sfarsit), care alege un numar la intamplare intre numarul declarat la start si numarul declarat la sfarsit. In cazul nostru va fi rand(0, 5). Codul pana aici este urmatorul:<?php$clipuri = array(0 => "wK2U0dYZeQI",1 => "bWXazVhlyxQ",2 => "MMeP8kIUd60",3 => "wK2U0dYZeQI",4 => "YFK6H_CcuX8",5 => "ctLnNQOVg0E");$rand = $clipuri[rand(0, 5)];?>Codul clipului este memorat in variabila $rand. Acum nu ne mai ramane decat sa afisam clipul embeduit.<?php$clipuri = array(0 => "wK2U0dYZeQI",1 => "bWXazVhlyxQ",2 => "MMeP8kIUd60",3 => "wK2U0dYZeQI",4 => "YFK6H_CcuX8",5 => "ctLnNQOVg0E");$rand = $clipuri[rand(0, 5)];echo '<iframe width="425" height="349" src="http://www.youtube.com/embed/' . $rand . '" frameborder="0" allowfullscreen></iframe>';?>Am incercat sa explic cat am putut de bine. Daca nu ai inteles ceva, spune-mi. Quote Link to comment Share on other sites More sharing options...
nesuxro Posted July 21, 2011 Author Report Share Posted July 21, 2011 am inteles:)ms Quote Link to comment Share on other sites More sharing options...