我在网页上爆炸词语并使用这些词语。而且我在mysql数据库中有一些关于tat词的数据。我想用mysql数据显示每个单词。
说明:
我在数据库中有3个单词,如奥迪,欧宝,丰田
我使用explode命令并分隔每个单词
然后我想将$ query的输出放到每个单独的单词
听觉 - %25 欧宝 - %10 丰田 - %35function myoptions($aid,$opt){
$query = mysql_query("SELECT oy_secenek, count(*) / (SELECT count(*) FROM anket_oylar) * 100 as yuzde FROM anket_oylar WHERE oy_anket_id = '$aid' GROUP BY oy_secenek");
while ($row= row($query)){
$yuzde = $row["yuzde"];
echo '<br />'.$yuzde;
}
$bol = explode(",", $opt);
$seceneks = array();
foreach ($bol as $secenek){
$secenek = '<br /><input type="radio" name="secenek" id="'.ss(trim($secenek)).'" value="'.ss(trim($secenek)).'" >'.ss(trim($secenek)).' -> '.ss(trim($yuzde));
array_push($seceneks, $secenek);
}
echo implode("", $seceneks);
}
答案 0 :(得分:0)
根据您为功能提供的功能,它可能会在很多方面失败。如果发送1&amp;例如,“audi”,它会在explode()
失败。看看:
function myoptions($aid,$opt){
$seceneks = array();
$query = mysql_query("SELECT oy_secenek, count(*) / (SELECT count(*) FROM anket_oylar) * 100 as yuzde FROM anket_oylar WHERE oy_anket_id = '$aid' GROUP BY oy_secenek");
while ($row= row($query)){
$yuzde = $row["yuzde"];
echo '<br />'.$yuzde;
if(strpos($opt, ",")){
$bol = explode(",", $opt);
} else {
$bol = array($opt);
}
foreach ($bol as $b){
$seceneks[] = '<br /><input type="radio" name="secenek" id="'.ss(trim($b)).'" value="'.ss(trim($b)).'" >'.ss(trim($b)).' -> '.ss(trim($yuzde));
}
}
if(count($seceneks)){
echo implode("", $seceneks);
} else {
return FALSE;
}
}