<div>不会出现</div>

时间:2011-01-31 11:26:58

标签: php html

所以这就是index.php的样子:

<div id="wrapper"> 
    <div id="header"> 
        <div id="logo"> 
            <h1>...</h1> 
        </div> 
        <div id="nav-bar"> 
        ...
        </div> 
    </div> 
    <div id="content"> 
        <div id="main"> 
            <div id="posts"> 
                ...
            </div> 
            <div id="pages"> 
                ...
            </div> 
        </div> 
        <div id="countries"> 
             <ul> 
                <li></li>  
                ...            
             </ul> 
        </div> 
    </div> 
        <div id="adverts"> 
            ...
        </div> 

然后我调用ajax函数ajax.query("page.php?category=culture&limit=5&c=1","content")来改变“content”div。 这就是page.php的实际情况:

<?php
    include 'class/mysql.php';
    $mysql=new connection();

    $rows=count($mysql->db->query("select url from video")->fetchAll());
    $url='page.php?';
    $div='"main"';
    $limit=5;


    if(isset($_GET['category'])&&(!isset($_GET['country']))){
        $query='select video.url from video inner join videoCat on video.url=videoCat.url
            where category="'.$_GET['category'].'" group by postDate desc limit ';
        $rows=count($mysql->db->query("select video.url from video inner join videoCat
                on video.url=videoCat.url where category='{$_GET['category']}'")->fetchAll());
        $url='page.php?category='.$_GET['category'].'&';
    }

    if(isset($_GET['category'])&&isset($_GET['country'])){
        $query='select video.url from video inner join videoCat on video.url=videoCat.url
            where category="'.$_GET['category'].'" and country="'.$_GET['country'].'"group by postDate desc limit ';
        $rows=count($mysql->db->query("select video.url from video inner join videoCat
                on video.url=videoCat.url where category='{$_GET['category']}' and country='{$_GET['country']}'")->fetchAll());
        $url='page.php?category='.$_GET['category'].'&country='.$_GET['category'].'&';
    }

    $output=$mysql->db->query($query.$_GET['limit'])->fetchAll();
    if(isset($_GET['c'])) echo '<div id="main">';
    echo '<div id="posts">';
    foreach($output as $i => $result){
        preg_match('/[a-zA-Z0-9-_]{11}/',$result['url'],$match);
        echo '<p><object width="95%" height="55%"><param name="movie"
            value="http://www.youtube.com/v/'.$match[0].'?fs=1&amp;hl=en_US&rel=0">
            </param><param name="allowFullScreen" value="true"></param>
            <param name="allowscriptaccess" value="always"></param>
            <embed src="http://www.youtube.com/v/'.$match[0].'?fs=1&amp;hl=en_US&rel=0"
            type="application/x-shockwave-flash" allowscriptaccess="always"
            allowfullscreen="true" width="95%" height="55%"></embed></object></p><br/>';
    }
    echo '</div>';

    echo '<div id="pages">';
    for($i=0;$i<=(int)($rows/$limit);$i++){
        if($i==(int)($rows/$limit)&&($rows%$limit==0))
            break;
        $_limit=$limit*$i.','.$limit;
        $_url='"'.$url.'limit='.$_limit.'"';
        echo "<a href='javascript:ajax.query({$_url},{$div})'>".($i+1)." </a>";
    }
    echo '<br/><br/></div></div>';
    if(isset($_GET['c'])) echo '</div>';

    if(isset($_GET['c'])) {
        echo '<div id="countries"><ul>';
        $output=$mysql->db->query("select country,count(country) from video inner join videoCat
            on video.url=videoCat.url where category='{$_GET['category']}' and
            country='{$_GET['country']}' group by country asc")->fetchAll();
        foreach($output as $result){
            $_url='"'.$url.'limit='.$limit;
            echo "<li><a href='javascript:ajax.query({$_url},{$div})'>
            {$result['country']}</a>({$result['count(country)']})</li>";
        }
        echo '</ul></div>';
    }
?>

最后我的页面看起来几乎没有,只是缺少<div id='countries'>。 这是the link to the page 非常感谢

1 个答案:

答案 0 :(得分:0)

您要查找变量c

if(isset($_GET['c']))

没有提供,该变量被称为“国家/地区”。 (由firebug的网络标签报道)

http://lookaroundyou.net/page.php?limit=1&country=croatia
http://lookaroundyou.net/page.php?limit=1&c=croatia