Jump to content

If video isnt present hide player


adman4054

Recommended Posts

Hoping someone could help me with hiding a video player if a video is not present in the db. I have split up the code to make it easier to understand. Thanks in advance  :)

 





(int) $ListId=$_GET['ListID'];
  function mysql_resultTo2DAssocArray ( $result) {
		$i=0;
		$ret = array();
		while ($row = mysql_fetch_assoc($result)) {
			foreach ($row as $key => $value) {
				$ret[$i][$key] = $value;
				}
			$i++;
			}
		return ($ret);


--------------------------------------------------------------------------------------------


$querys = mysql_query("SELECT * FROM video WHERE listingID = '$ListId' ");
  $Details_video=mysql_resultTo2DAssocArray ($querys);				 


--------------------------------------------------------------------------------------------




<div class="right_col">

<p id='preview'>The player will show in this paragraph</p>

<script type='text/javascript' src='/flvPlayer/swfobject.js'></script>
<script type='text/javascript'>
var s1 = new SWFObject('/flvPlayer/player-viral.swf','player','280','200','9');
s1.addParam('allowfullscreen','true');
s1.addParam('allowscriptaccess','always');
s1.addParam('autostart','true');
s1.addParam('image','/flvfiles/<?php echo $Details_video[0]['imagePath']?>');

s1.addParam('flashvars','&file=/flvfiles/<?php echo $Details_video[0]['videoPath']?>&image=/flvfiles/<?php echo $Deatls_video[0]['imagePath']?>&dock=false&autostart=true');
s1.write('preview');
</script>

Link to comment
https://forums.phpfreaks.com/topic/226845-if-video-isnt-present-hide-player/
Share on other sites

Probably the best way would be just to wrap your html video code inside of if-statement which checks wether $Details_video is empty or not.. Depending on your layout it'll probably still require some place holder.

 

if(!empty($Details_video[0]['videoPath'])) { ?>
  <!-- your video script here -->
<?php
}

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.