this is my first question here. I'm facing a problem that is literally driving me crazy. I'm new to PHP and I feel that it is something really simple that I just can't figure out.
I have this code:
$busca_alimento = mysql_query("SELECT * FROM alimentos");
if (empty($busca_alimento)) {
echo 'Nothing found';
}
$count = 0;
while ($alimento_informacoes = mysql_fetch_array($busca_alimento)) {
$alimento_id[$count++] = $alimento_informacoes['id'];
$alimento_categoria[$count++] = $alimento_informacoes['categoria'];
$alimento_nome[$count++] = $alimento_informacoes['nome'];
$alimento_quantidade[$count++] = $alimento_informacoes['quantidade'];
}
I want to fetch the ID, Categoria, Nome and Quantidade rows and store the data in those vars like this:
$alimento_id[1]
$alimento_categoria[1]
$alimento_nome[1]
$alimento_quantidade[1]
but what is happening is this:
$alimento_id[1]
$alimento_categoria[2]
$alimento_nome[3]
$alimento_quantidade[4]
Does anyone know what's happening and how can I solve this? Thank you