0
Hello, I’m having problems, in my database table I have 3 records, I use the code below to fetch them:
public function buscarMateriaProva($codigoProva){
$query = " SELECT codigoMateria, codigoProva, quantidadeQuestao
FROM materiasProvas
WHERE codigoProva = ".$codigoProva;
//se for executado
if($res = mysql_query($query)){
$row = mysql_fetch_row($res);
$nr = (int)mysql_num_rows($res);
#se houver registro povoa o obj, senão retorna falso
if($nr === 0){
return false;
} else {
return $res;
}
} else {
return false;
}
}
In this case, the $nr has value 3, because it is 3 records, so far so good.
The value returns to my file where I mount the structure using mysql_fetch_array():
$resMateriaProva = $materiaProva->buscarMateriaProva($codigo);
while($arrayMateriaProva = mysql_fetch_array($resMateriaProva)){
print_r($arrayMateriaProva);
}
It returns the 3 records, normal, but only displays the last 2, ignoring the first record.
Someone knows what the mistake is?
From now on, thank you!
Mysql is susceptible to hacking because you don’t update to Pdo or mysqli?
– Florida