如果使用get url则为multiple [英] multiple if in if with get url
本文介绍了如果使用get url则为multiple的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过网址从数据库中进行选择,为此我会这样做:
i want to select from database by url and for this i do this if:
if (isset($_GET['class']) == 'dw')
{
$query = mssql_query("select * from [WebShop] where [category]='".secure($string)."' and [dw] > 0 order by credits asc");
}
if (isset($_GET['class']) == 'bk')
{
$query = mssql_query("select * from [WebShop] where [category]='".secure($string)."' and [bk] > 0 order by credits asc");
}
if (isset($_GET['class']) == 'fe')
{
$query = mssql_query("select * from [WebShop] where [category]='".secure($string)."' and [fe] > 0 order by credits asc");
}
if (isset($_GET['class']) == 'mf')
{
$query = mssql_query("select * from [WebShop] where [category]='".secure($string)."' and [mf] > 0 order by credits asc");
}
if (isset($_GET['class']) == 'dl')
{
$query = mssql_query("select * from [WebShop] where [category]='".secure($string)."' and [dl] > 0 order by credits asc");
}
if (isset($_GET['class']) == 'sum')
{
$query = mssql_query("select * from [WebShop] where [category]='".secure($string)."' and [sum] > 0 order by credits asc");
}
if (isset($_GET['class']) == 'rf')
{
$query = mssql_query("select * from [WebShop] where [category]='".secure($string)."' and [rf] > 0 order by credits asc");
}
else
{
$query = mssql_query("select * from [WebShop] where [category]='".secure($string)."' order by credits asc");
}
网址为: index.php?sy = items& class = dw
但是当我访问此网址 index.php?sy = items& class =如果:(:
index.php?sy = items& class = rf
可以帮我解决每个if的工作吗?
can help me to resolve for work with each if ?
推荐答案
这里尝试更改代码的格式这种模式...
Here Try to change the format of your code in this pattern...
$class=$_GET['class']
switch($class) {
case 'dw':
$query = mssql_query("select * from [WebShop] where [category]='".secure($string)."' and [dw] > 0 order by credits asc");
break;
case 'bk':
$query = mssql_query("select * from [WebShop] where [category]='".secure($string)."' and [bk] > 0 order by credits asc");
break;
case 'fe':
$query = mssql_query("select * from [WebShop] where [category]='".secure($string)."' and [fe] > 0 order by credits asc");
break;
default:
code to be executed if n is different from all labels;
}
这篇关于如果使用get url则为multiple的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文