我在我的表中的列,infoanimal
:分組陣列在PHP
RABBIT || Male || 15
HAMSTER || Female || 10
FROG || Male || 5
RABBIT || Male || 40
HAMSTER || Male || 4
FROG || Male || 13
我有這個在以下時刻:
$sql = "SELECT * FROM experimental";
$query5 = mysql_query($sql);
while ($dados = @mysql_fetch_array($query)){
$infoanimal = $dados["infoanimal"];
$pesquisa = explode(">>", $infoanimal);
$num_pesq = count($pesquisa);
for($i=1;$i<$num_pesq;$i++){
$dadosx3 = explode("||", $pesquisa[$i]);
$animal[0] = $dadosx3[0];
$gender[0] = $dadosx3[1];
$amount[0] = $dadosx3[5];
}
}
我想提出以下幾點:
Animal || Male || Female || Sum
HAMSTER || 4 || 10 || 14
FROG || 18 || 0 || 18
RABBIT || 40 || 0 || 40
你能解決你的格式嗎?用4個空格縮進代碼,並確保它前面有一個空行。 – dave 2013-05-07 20:03:16