我试图过滤各种自行车女士、男士、儿童。我写了一个函数,将我们的一串数字排序为所选类型的自行车。
function: bicycle($stringnumbers, $sortbicycle)
脚本:
function bicycle($stringnumbers, $sortbicycle){
$bicycle = explode(',', $bicyclenumbers);
foreach($bicycle as $bicycle1)
{
$sql2 = "SELECT * FROM `bicycle` WHERE `bicyclenumber` LIKE '".$bicycle1."' LIMIT 0, 30 ";
$number = mysql_query($sql2)or die(mysql_error());
while ($bicycleinfo = mysql_fetch_array($number))
{
$number1 = $bicycleinfo['sortbicycle'];
if($sortbicycle == "kid")
{
if($number1 == "boy")
{
$totaal .= "J " . $bicycle1 . ",";
}
elseif($number1 == "girl")
{
$totaal .= "M " . $bicycle1 . ",";
}
}
elseif($sortbicycle == "kids")
{
if ($number1 == "boy")
{
$totaal .= $bicycle1 . ",";
}
elseif($number1 == "girl")
{
$totaal .= $bicycle1 . ",";
}
}
elseif($number1 == $sortbicycle)
{
$totaal .= $bicycle1 . ",";
}
}
}
if($totaal > "1")
{
$amount1 = $total;
}
else
{
$amount1 = "";
}
return $amount1;
}
但由于某种原因,这部分:
if ($number1 == "boy")
{
$totaal .= "J " . $bicycle1 . ",";
}
elseif ($number1 == "girl")
{
$totaal .= "M " . $bicycle1 . ",";
}
}
elseif ($sortbicycle == "kids")
{
if ($number1 == "boy")
{
$totaal .= $bicycle1 . ",";
}
elseif ($number1 == "girl")
{
$totaal .= $bicycle1 . ",";
}
}
没有按应有的方式工作,第一部分“孩子”部分有效,但是当我删除
$totaal .= "J " . $bicycle1 . ",";
至
$totaal .= $bicycle1 . ",";
我究竟做错了什么?