Online graphic php

Asked

Viewed 45 times

0

I’m trying to plot online but I’m having trouble in the

mysql_fetch_array() expects Parameter 1 to be Resource

This error appears to me, if you can help me to have a hint thank you. follows 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>  ";


    }

    ?>
  • 1

    Some people think Stackoverflow users have telepathic magical powers of clairvoyance. They believe that these superpowered Stackoverflownian beings can guess what the code is, the error message, and all the other necessary information is without needing to see anything about it and are still able to figure out what’s wrong with it all. Thus, these users believe that it is not necessary to place this information in the text of the question because it can be obtained by those who answer through supernatural and paranormal means.

  • Welcome, some posts you should read to succeed in your questions https://answall.com/help/mcve. and more https://pt.meta.stackoverflow.com/questions/1078/como-e-por-que-aceitar-uma-resposta/1079#1079

1 answer

0

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

so you can 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>  ";


    }

?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.