Jump to content

Recommended Posts

Posted (edited)

Boa tarde, tenho uma duvida quanto a um código php que estou a desenvolver, a questão é que quero fazer uma média, a consulta no MySql funciona mas na meu servidor dá o erro Resource id#5,

$resultado_pph = mysql_query("select turno,avg(pph) from producao where turno=1 and data=current_date group by turno");
$med_pph = ($resultado_pph) or die(mysql_error());
echo "<center><font face=\"arial\" size=\"3\">Média do PPH: $med_pph</font></center>";

o resultado é o seguinte:

http://prntscr.com/w122k

fiz umas pesquisas e dizem que tenho que usar mysql_fetch_assoc($resultado_pph), mas continua a não estar correcto e obtenho o seguinte:

http://prntscr.com/w11zo

Alguém me sabe ajudar?

Edited by brunoais
geshi
Posted (edited)
 select turno,
        avg(pph) AS MEDIA
   from producao
  where turno=1
    and data=current_date
group by turno

$record = mysql_fetch_assoc($resultado_pph);
echo "<center><font face='arial' size='3'>Média do PPH: {$record['MEDIA']}</font></center>";
Edited by HappyHippyHippo
IRC : sim, é algo que ainda existe >> #p@p

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.