i am trying to make a func开发者_JAVA技巧tion that will add a video on some posts i have.
At the moement i am using this function :
function singleVideo($id = '') {
$id = mysql_real_escape_string ($id);
$sql = "SELECT post_excerpt,vid,file FROM wp_posts,wp_wordtube WHERE post_excerpt = vid ";
$res = mysql_query($sql) or die (mysql_error());
if (mysql_num_rows($res) !=0):
$row = mysql_fetch_assoc($res);
echo "
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='640' height='360' id='single1' name='single1'>
<param name='movie' value='videos/player.swf'>
<param name='allowfullscreen' value='false'>
<param name='allowscriptaccess' value='always'>
<param name='wmode' value='transparent'>
<param name='flashvars' value='file=".$row['file']."'>
<embed
type='application/x-shockwave-flash'
id='single2'
name='single2'
src='videos/player.swf'
width='640'
height='360'
bgcolor='undefined'
allowscriptaccess='always'
allowfullscreen='false'
wmode='transparent'
flashvars='file=".$row['file']."'
/>
</object>
"; //echo
else:
echo 'This page dont exist';
endif;
} // end
But there is a problem, the object
is showed on every post even if the post_excerp
t is 0.
So what i am asking is:
- i want that the function
singleVideo()
to be showed only at the posts that haspost_excerpt
!=0 or null
Thank you for reading..
EDITED
I have changed my function in this one,but it is not showing any kind of video now!!
function singleVideo($id = '') {
$id = mysql_real_escape_string ($id);
$sql = "SELECT * FROM wp_posts,wp_wordtube WHERE ID='$id' AND post_excerpt = vid ";
$res = mysql_query($sql) or die (mysql_error());
$row = mysql_fetch_assoc($res);
if($row["post_excerpt"] != 0) {
echo "
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='640' height='360' id='single1' name='single1'>
<param name='movie' value='videos/player.swf'>
<param name='allowfullscreen' value='false'>
<param name='allowscriptaccess' value='always'>
<param name='wmode' value='transparent'>
<param name='flashvars' value='file=".$row['file']."'>
<embed
type='application/x-shockwave-flash'
id='single2'
name='single2'
src='videos/player.swf'
width='640'
height='360'
bgcolor='undefined'
allowscriptaccess='always'
allowfullscreen='false'
wmode='transparent'
flashvars='file=".$row['file']."'
/>
</object>
";
}
} // end
Something like this?
$sql = "SELECT post_excerpt,vid,file FROM wp_posts,wp_wordtube WHERE post_excerpt = vid AND post_excerpt != 0";
function singleVideo($id = '') {
$id = mysql_real_escape_string ($id);
$sql = "SELECT post_excerpt,vid,file FROM wp_posts,wp_wordtube WHERE post_excerpt = vid ";
$res = mysql_query($sql) or die (mysql_error());
$row = mysql_fetch_assoc($res);
if($row["post_excerpt"] != 0 && !is_null($row["post_excerpt"])){
echo "
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='640' height='360' id='single1' name='single1'>
<param name='movie' value='videos/player.swf'>
<param name='allowfullscreen' value='false'>
<param name='allowscriptaccess' value='always'>
<param name='wmode' value='transparent'>
<param name='flashvars' value='file=".$row['file']."'>
<embed
type='application/x-shockwave-flash'
id='single2'
name='single2'
src='videos/player.swf'
width='640'
height='360'
bgcolor='undefined'
allowscriptaccess='always'
allowfullscreen='false'
wmode='transparent'
flashvars='file=".$row['file']."'
/>
</object>
";
} else{
echo 'This page dont exist';
}
}
精彩评论