快速问题除了过滤器方面,我有一个功能齐全的数据库网站。我有一个JavaScript过滤器,但它不能正常工作,因为它通过li类过滤并使其成为li class ='。名称 。 ' 不工作。使用php过滤if语句
无论如何,我试图用这种方法来解决过滤器问题。
但是,我不知道在哪里运行的查询不会创建一个错误,因此为什么它被注释掉。任何人都可以提供帮助,甚至可以提出一个更好的解决方法吗?
$result = mysql_query("SELECT * FROM ddcompanies");
/*
while($row = mysql_fetch_array($result)) {
$cname = $row["company"]; //runs through the company column and populates the array varcompany with those names
$csect = $row["sector"]; //runs through the website column and populates the array varwebsite with those names
$cslog = $row["slogan"]; //runs through the story column and populates the array varstory with the text
*/
echo "<ul id='portfolio'>";
if($_GET['link']=='design'){
echo "design";// TEST
$result .= "AND sector = 'design'";
echo "<li>
<a href='single.php?link=" . $cname . "'><img src='images/companies/" . $cname . ".png' alt='' height='115' width='200' />$cname</a>
<div id='sector'>$csect</div>
<div id='details'>$cslog</div>
</li>";
}else{
echo "no way";// TEST
};
希望你能帮助,甚至告诉我一个更好的方式来做它请。
在此先感谢!
* 编辑 **
在我的索引页,我有一个网格或链接(其中有一个形象和一些信息都是从数据库中抽取)画廊。
每个数据库条目都有一个称为扇区的字段。
我希望能够仅显示(过滤)属于例如数字(扇区名称)或非数字(扇区名称)。
因此,过滤器将使用每个数据库条目中的扇区字段值。
此刻,我在过滤索引页上的链接如下所示。设计或开发
我希望这已经够清楚了。
*编辑* *
//QUERY IN EACH
$query = "SELECT * FROM ddcompanies ";
if($_GET['link']=='design') {
$query .= "WHERE sector = 'design'";
$result = mysql_query($query);
}elseif($_GET['link']=='development') {
$query .= "WHERE sector = 'development'";
$result = mysql_query($query);
};
//OR
$query = "SELECT * FROM ddcompanies ";
if($_GET['link']=='design') {
$query .= "WHERE sector = 'design'";
}elseif($_GET['link']=='development') {
$query .= "WHERE sector = 'development'";
};
$result = mysql_query($query);
你到底想干什么?你的问题不清楚。 – 2012-02-02 22:49:04
我很困惑,你想做什么? – 2012-02-02 22:49:40
你正在尝试做什么? – Joe 2012-02-02 22:51:43