[英]Show function only one some posts?
i am trying to make a function 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. 但是有一个问题,即使post_excerp
t为0,该object
也会显示在每个帖子上。
So what i am asking is: 所以我要问的是:
singleVideo()
to be showed only at the posts that has post_excerpt
!=0 or null 我希望仅在具有post_excerpt
!= 0或null的帖子上显示功能singleVideo()
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"; $ sql =“ SELECT post_excerpt,vid,来自wp_posts,wp_wordtube的文件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';
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.