[英]Show function only one some posts?
我试图做一个功能,可以在我的某些帖子上添加视频。
目前我正在使用此功能:
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
但是有一个问题,即使post_excerp
t为0,该object
也会显示在每个帖子上。
所以我要问的是:
post_excerpt
!= 0或null的帖子上显示功能singleVideo()
感谢您的阅读..
已编辑
我已经更改了此功能,但是现在没有显示任何视频!!
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
像这样吗
$ 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.