开发者

Show function only one some posts?

开发者 https://www.devze.com 2023-04-02 02:29 出处:网络
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 :

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_excerpt is 0.

So what i am asking is:

  • i want that the function singleVideo() to be showed only at the posts that has post_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';
    }
    } 
0

精彩评论

暂无评论...
验证码 换一张
取 消