Domanda

What I'm trying to do is take a YouTube playlist (http://www.youtube.com/embed/videoseries?list=PLzMZz3zuUATIdU0RIndFQiQQzADew0hZq&index= RANDOM NUMBER), and call the random number inside an tag.

This is the code so far:

<?php
$min=1;  $max=4;
$z = init rand(1, 4)
?>
<object width="375" height="100"><param name="movie" value="http://www.youtube.com/embed/videoseries?list=PLzMZz3zuUATIdU0RIndFQiQQzADew0hZq"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="375" height="100" allowscriptaccess="always" allowfullscreen="false" src="http://www.youtube.com/embed/videoseries?list=PLzMZz3zuUATIdU0RIndFQiQQzADew0hZq&index=<? $z ?>"></embed></object>
<?php
$min=1;  $max=4;
$z = init rand(1, 4)
?>

Where you see the link followed by index= is where I would like to place the random number. Therefor, if the random number is 4, then the index should end up as <embed... ...hZq&index=4"></embed>

I cannot find my way through this code. Help would be much appreciated!

È stato utile?

Soluzione

You're missing your echo statement (and depending on your setup, you complete opening PHP tag):

<? $z ?>

should be:

<? echo $z ?> or <?php echo $z ?>

or, if you have short tags enabled or are using PHP 5.4+:

<?= $z ?>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top