Search the Community
Showing results for tags 'table dinamic'.
-
Hello Friends ? Could anyone help me This is my name mysql database: lc_movimento | Id | data | description | value I'm using this code below is giving the error. could someone tell me what I doing wrong Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in <?php include"config.php"; //$pdo = new PDO("mysql:host=localhost;dbname=mrangelc_teste", "mrangelc_01", "kov6095" ); //$pdo = new PDO('pgsql:<conn-string>'); $query = mysql_query("select (('month',CURRENT_DATE) + CAST(FLOOR(s.idx / 5) || ' day' as interval))::DATE AS data, 'descricao' as descricao, CASE WHEN random() < 0.5 THEN ROUND(150 + (random()*100)::numeric,2) ELSE ROUND(150 + (random()*100)::numeric,2) * -1 END as valor from lc_movimento(1,24) as s(idx)"); $ultimaData = null; $acumulado = 0; $totalEntradaDia = 0; $totalSaidaDia = 0; echo '<table>'; while ($resultado = mysql_fetch_array($query)) { $date = DateTime::createFromFormat('Y-m-d', $row['data']); $key = $date->format('Ymd'); if($ultimaData !== null && $ultimaData != $key) { printf('<tr><td colspan="2">Entrada: %s, Saida: %s, Saldo dia: %s, Saldo acumulado: %s</td></tr>', number_format($totalEntradaDia,2,',','.'), number_format($totalSaidaDia,2,',','.'), number_format($totalEntradaDia + $totalSaidaDia,2,',','.'), number_format($acumulado,2,',','.') ); $totalSaidaDia = 0; $totalEntradaDia = 0; } $ultimaData = $key; printf('<tr><td>%s</td><td>%s</td><td>R$ %s</td></tr>', $date->format('d'), $row['descricao'], number_format($row['valor'],2,',','.') ); if($row['valor'] > 0) { $totalEntradaDia += $row['valor']; } else { $totalSaidaDia += $row['valor']; } $acumulado += $row['valor']; } echo '</table>'; printf('<tr><td colspan="2">Entrada: %s, Saida: %s, Saldo dia: %s, Saldo acumulado: %s</td></tr>', number_format($totalEntradaDia,2,',','.'), number_format($totalSaidaDia,2,',','.'), number_format($totalEntradaDia + $totalSaidaDia,2,',','.'), number_format($acumulado,2,',','.') ); Thanks to all