Online php graphic

0

I'm trying to mount graphics online but I'm having trouble on

  

mysql_fetch_array () expects parameter 1 to be resource

This error appears to me, if you can help me get a thank you. follow code:

<?
include"conexao.php"; 
$seleciona_artigos = mysql_query("SELECT * FROM  artigo order by artigo_visual desc " );
$seleciona_total_grafico = mysql_query("SELECT artigo_visual FROM  artigo order by artigo_visual desc ");
$lin_total_grafico = mysql_fetch_array($seleciona_total_grafico);

?>


<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Highcharts Example</title>


    </head>
    <body>

    <?

    while($lin_artigo = mysql_fetch_array($seleciona_artigos)){

    $total_largura = ($lin_artigo ['artigo_visual']/$lin_total_grafico['artigo_visual'])*100;

    echo"<div style='width:40px;background:#ccc;'>

    <div style='background:#ccc;width:".$total_largura.";margin:5px 0;heigth:40px;display:table;line-heigth:30px;position:relative;'>

    <div style='position:absolute;width:400px;padding:5px;'>".$lin_artigo['artigo_titulo']." - ".$lin_artigo['artigo_visual']." visiatas

    <div style='display:table;float:right;padding:0 10px 0 0;'>".round($total_largura )."%</div>
</div>  
</div>  ";


    }

    ?>
    
asked by anonymous 17.09.2017 / 05:40

1 answer

0

I ran your code and no error appeared, this line ".$lin_artigo['artigo_titulo']." - ".$lin_artigo['artigo_visual']." seems to be a concatenation when it seems to me that it should be a subtraction because it refers to something visitadas

from qq form see if this gives what you want

<?php
include"conexao.php"; 
$seleciona_total_grafico = mysql_query('SELECT SUM(artigo_visual) AS value_sum FROM artigo'); 
$row = mysql_fetch_assoc($seleciona_total_grafico); 
$sum = $row['value_sum'];

$seleciona_artigos = mysql_query("SELECT * FROM artigo order by artigo_visual desc " );

?>


<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Highcharts Example</title>


    </head>
    <body>

<?php

    while($lin_artigo = mysql_fetch_array($seleciona_artigos)){

    $total_largura = ($lin_artigo ['artigo_visual']/$sum)*100;

    echo"<div style='width:40px;background:#ccc;'>

    <div style='background:#ccc;width:".$total_largura.";margin:5px 0;heigth:40px;display:table;line-heigth:30px;position:relative;'>

    <div style='position:absolute;width:400px;padding:5px;'>".$lin_artigo['artigo_titulo'] - $lin_artigo['artigo_visual']." visitadas

    <div style='display:table;float:right;padding:0 10px 0 0;'>".round($total_largura )."%</div>
</div>  
</div>  ";


    }

?>
    
17.09.2017 / 07:47