代码如下:
index.php<?php    include("dbinfo.inc.php");
    echo " <div class=\"index_menu_container\">
            <ul>
<li id=\"index_button_hp\"><a class=\"container_hp\" href=\"index.php?brand=hp\" ><span>HP</span></a></li>
<li id=\"index_button_apple\"><a class=\"container_apple\" href=\"index.php?brand=apple\" ><span>APPLE</span></a></li>
<li id=\"index_button_lenovo\"><a class=\"container_lenovo\" href=\"index.php?brand=lenovo\" ><span>LENOVO</span></a></li>
<li id=\"index_button_hasee\"><a class=\"container_hasee\" href=\"index.php?brand=hasee\" ><span>HASEE</span></a></li>
<li id=\"index_button_dell\"><a class=\"container_dell\" href=\"index.php?brand=dell\" ><span>DELL</span></a></li>
</ul>  
            </div> ";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database"); mysql_query("SET NAME 'UTF8'"); 
mysql_query("SET CHARACTER SET UTF8"); 
mysql_query("SET CHARACTER_SET_RESULTS=UTF8'");  if($_GET('brand')== 'hp'&& $_GET('brand')== ''){
$query="SELECT * FROM laptop where name like 'HP%'";
$result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Laptop Database Output</center></b><br><br>"; $i=0;
while ($i < $num) { $name=mysql_result($result,$i,"name");
$price=mysql_result($result,$i,"price");
$time=mysql_result($result,$i,"time");
$img=mysql_result($result,$i,"img");
$weight=mysql_result($result,$i,"weight");

echo "<div class=\"laptop_container\">

        <div class=\"laptop_img_container\"><img src=\"/computer/images/$img\"></img></div>

<div class=\"laptop_content\">

<ul><li>name:$name</li>
  <li>price: $price</li>
  <li>time: $time</li>
  <li>weight: $weight</li>
    </ul>
        </div>                              

      </div>";
$i++;
}
    }

    if($_GET('brand')== 'apple'){
$query="SELECT * FROM laptop where name like 'Apple%'";
$result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Laptop Database Output</center></b><br><br>"; $i=0;
while ($i < $num) { $name=mysql_result($result,$i,"name");
$price=mysql_result($result,$i,"price");
$time=mysql_result($result,$i,"time");
$img=mysql_result($result,$i,"img");
$weight=mysql_result($result,$i,"weight");

echo "<div class=\"laptop_container\">

        <div class=\"laptop_img_container\"><img src=\"/computer/images/$img\"></img></div>

<div class=\"laptop_content\">

<ul><li>name:$name</li>
  <li>price: $price</li>
  <li>time: $time</li>
  <li>weight: $weight</li>
    </ul>
        </div>                              

      </div>";
$i++;
}
    }
if($_GET('brand')== 'hp'&& $_GET('brand')== ''){
$query="SELECT * FROM laptop where name like 'HP%'";
$result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Laptop Database Output</center></b><br><br>"; $i=0;
while ($i < $num) { $name=mysql_result($result,$i,"name");
$price=mysql_result($result,$i,"price");
$time=mysql_result($result,$i,"time");
$img=mysql_result($result,$i,"img");
$weight=mysql_result($result,$i,"weight");

echo "<div class=\"laptop_container\">

        <div class=\"laptop_img_container\"><img src=\"/computer/images/$img\"></img></div>

<div class=\"laptop_content\">

<ul><li>name:$name</li>
  <li>price: $price</li>
  <li>time: $time</li>
  <li>weight: $weight</li>
    </ul>
        </div>                              

      </div>";
$i++;
}
    }}
单是提示有问题啊。Fatal error: Function name must be a string in D:\www\computer\index.php on line 27。
php如何从url来传参数和获取参数啊。高手帮忙看下吧,谢谢了。
我这样写对吗?if($_GET('brand')== 'hp'&& $_GET('brand')== '')。

解决方案 »

  1.   

    if($_GET['brand']== 'hp'&& $_GET['brand']== '')
      

  2.   

    if($_GET('brand')== 'hp'&& $_GET('brand')== '')
    {
    }
    //也不能说错,但是这个条件,大概只有一种情况是会执行,花括弧里的代码那就是
    if(0 == 'hp' && 0 == '')
    {
    echo 1;//这种情况会打印1,
    }27行是哪一行呢,你的代码乱啊$num=mysql_numrows($result);//这个除非你单独定义过,,通常应该是$num=mysql_num_rows($result);