$sql = mysql_query("SELECT DISTINCT business_region FROM business WHERE business_category='occupation'");
// count the output amount
$businessCount = mysql_num_rows($sql);
if ($businessCount > 0) {
while ($row = mysql_fetch_array($sql)) {
$business_region = $row["business_region"];
$Region_view .= "display value";
}
}
得到以下结果:
密歇根州多伦多俄亥俄州曼彻斯特伦敦悉尼巴黎
我想选择只能Ohio and London
作为变量值:
$Region_view .
也许我可以使用if else结构,但无法使其正常工作。
即我只需要选择Ohio, London
我可以使用联合MySQL语句来完成此操作,但是它太慢了,因此我需要并要求使用其他方法。
$sql = mysql_query("SELECT DISTINCT business_region FROM business WHERE business_category ='occupation'");
// count the output amount
$businessCount = mysql_num_rows($sql);
if ($businessCount > 0) {
while($row = mysql_fetch_array($sql)){
$business_region = $row["business_region"];
if ($business_region == 'Ohio' || $business_region == 'London') // added
$Region_view .= $business_region;//changed
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句