Jump to content

Random image via PHP


hey_suburbia

Recommended Posts

Here is a snippet of code I have to populate images and use glider.js to power the image viewer, but I need to make each image random... Any thoughts?

 

Code:

<?php
	foreach ($videos as $video):
		$video_count++;
		if ($video->header=="")
			$play="true";
		else
			$play="false";
		?>
		<div class="video-list-item">
			<a href="javascript:switchHeader('<?=$video->text1?>','<?=$video->file?>','<?=$video->header?>','<?=$video->link?>',<?=$play?>,true)">
			<img style='float:left;' src="<?=$this->baseurl?>/images/videos/<?=$video->thumbnail?>">
			</a>
			<div class='wrapper'>
				<h3><a href="javascript:switchHeader('<?=$video->text1?>','<?=$video->file?>','<?=$video->header?>','<?=$video->link?>',<?=$play?>,true)"><?=$video->text1?></a></h3>
				<p class='black' ><?=$video->text2?></p>
				<p style='font-weight: normal' class='black' ><?=$video->text3?></p>
			</div>
			<a href="javascript:switchHeader('<?=$video->text1?>','<?=$video->file?>','<?=$video->header?>','<?=$video->link?>',<?=$play?>,true)">> VIEW</a>
		</div>
		<?php if ($video_count%3==0 && count($videos)!=$video_count) print "</li><li>"; ?>
	<?php endforeach; ?></li>

 

Site for reference (The images in the yellow bar):

http://www.nhsonline.org/

Link to comment
https://forums.phpfreaks.com/topic/192965-random-image-via-php/
Share on other sites

Thanks, but when I did this:

<?php
shuffle($videos)
	foreach ($videos as $video):
		$video_count++;
		if ($video->header=="")
			$play="true";
		else
			$play="false";
		?>

 

I got this:

Parse error: syntax error, unexpected T_FOREACH in /nfs/c04/h03/mnt/65395/domains/nhsonline.org/html/templates/nhs/glider.php  on line 10

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.