我的表中有列infoanimal
:
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