我正在尝试制作一个可以在我的某些帖子上添加视频的功能。
我正在使用这个功能:
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
但是有一个问题,即使object
t为0,每个帖子都会显示post_excerp
。
所以我要问的是:
singleVideo()
仅显示在post_excerpt
!= 0或null 感谢您阅读..
EDITED
我已经改变了我的功能,但它现在没有显示任何类型的视频!!
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
答案 0 :(得分:2)
这样的东西?
$ sql =“SELECT post_excerpt,vid,file FROM wp_posts,wp_wordtube WHERE post_excerpt = vid AND post_excerpt!= 0“;
答案 1 :(得分:1)
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';
}
}