-1

我尝试使用选择选项进行此搜索,以选择哪个站点或所有站点。当我单击所有站点时,它可以工作。当我单击“4shared”时,它可以工作。但是当我点击“putlocker”时,我明白了。查询为空。

我真的不知道我做错了什么

<?php 
include"inc/connect.php"; 
include"inc/functions.php";
error_reporting(0);
if(isset($_GET['s']) && $_GET['s'] != ""){
    $s = $_GET['s'];
    $w = $_GET['w'];

    if($w == 'all'){
        $sql = "SELECT * FROM result WHERE (`name` LIKE '%".$s."%') OR (`keywords` LIKE '%".$s."%')";
    }else if($w == 'Sockshare'){
        $sql = "SELECT * FROM result WHERE website='Sockshare' AND (`name` LIKE '%".$s."%') OR (`keywords` LIKE '%".$s."%')";
    }else if($w == 'Putlocker'){
        $sql == "SELECT * FROM result WHERE website='Putlocker' AND (`name` LIKE '%".$s."%') OR (`keywords` LIKE '%".$s."%')";
    }else if($w == '4shared'){
        $sql = "SELECT * FROM result WHERE website='4shared' AND (`name` LIKE '%".$s."%') OR (`keywords` LIKE '%".$s."%')";
    }else if($w == 'Rapidshare'){
        $sql = "SELECT * FROM result WHERE website='Rapidshare' AND (`name` LIKE '%".$s."%') OR (`keywords` LIKE '%".$s."%')";
    }

    $query = mysql_query($sql) or die(mysql_error());

    $count = mysql_num_rows($query);

    if($count > 1){
        while($row = mysql_fetch_array($query)){
            $name = $row["name"];
            $details = $row["details"];
            $url = $row["url"];

            $results .= '
            <div id="stitle">' .$name. '</div>
            <div id="details">' .$details. '</div>
            <div id="url"><a target="_blank" href="' .$url. '">' .$url. '</a></div>';
        }
        } else {
            $results = 'Nothing found!';
        }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Findrfile.com - Putlocker Search | Sockshare search | Mediafire Search</title>
<link href='http://fonts.googleapis.com/css?family=Orienta' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="main.css" />
</head>

<body>
<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<?php include"header.php"; ?>
<div id="spacer"></div>
<?php include"litsearch.php"; ?>
<div id="nuresults"><span class="blue"><?php echo $count; ?> Results found</span></div>
<div id="spacerx"></div>
<div id="wrapper">
<div id="spacerx"></div>
<div id="content">
<?php echo $results; ?>
<div class="clear"></div>

</div>
<div id="spacerx"></div>
<div id="spacer"></div>
</div>
<?php include"footer.php"; ?>
</body>
</html>
4

2 回答 2

1

您已经$sql == "SELECT * FROM result WHERE website='Putlocker' AND (name LIKE '%".$s."%') OR (keyword LIKE '%".$s."%')";注意到==,这是一个比较运算符,因此它不会设置值,$sql 我认为这可能是您的问题。

于 2013-03-02T18:04:52.703 回答
0

改变

while($row = mysql_fetch_array($query)){

while($row = mysql_fetch_assoc($query)){

因为您使用关联数组。

        $name = $row["name"];
        $details = $row["details"];
        $url = $row["url"];

如果你想使用

while($row = mysql_fetch_array($query)){

喜欢:

    $name = $row[0];
    $details = $row[1];
    $url = $row[2];

我错了吗?

还:

您检查是否设置了 $_GET["s"] 但不检查 $_GET["w"]

于 2013-03-02T17:57:21.627 回答