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
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
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.