Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6222205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:16:25+00:00 2026-05-24T08:16:25+00:00

I have a graph that auto fills based on a few values. The values

  • 0

I have a graph that auto fills based on a few values. The values are the goal (total) the current (where it is at now) and in the total height of the graph. I am trying to pull the goal and current out of the database format it into money and it should fill the graph to the point it needs to be.

I had it working with a URL get which was ?current=584559096&goal=1000000000 and I just used $_GET. For easier maintenance for others around I want to pull it from a database which can be updated a post.

The code I have so far is:

    <? php function formatMoney($number, $fractional=false) {
        if ($fractional) {
            $number = sprintf('%.0f', $number);
        }
        while (true) {
            $replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
            if ($replaced != $number) {
                $number = $replaced;
            } else {
                break;
            }
        }
        return $number;
    }

        $goal = $row['goal'];
        $current = $row['current'];
        $percent = round($current / $goal * 100);
        $totalheight = 216;
        $ourheight = $totalheight * $percent / 100;

        $halfofarrowheight = 12;
            $arrowheight = $totalheight-$ourheight-$halfofarrowheight; 
            if($arrowheight < 0)
                $arrowheight = 0;
    mysql_close($con);
?>

Here is my query

mysql_select_db("databasename", $con);

$result = mysql_query("select * from `dbname`.`tablename");

This is my error Warning: Division by zero in E:\inetpub\wwwroot\test.website.net\web\includes\globalfoot.php on line 36

Line 36 is the $percent = round($current / $goal * 100);

So, I been fooling with this thing for 4 days now trying to just get the numbers out of the goal column and current column format them to money and have the chart fill. For test sake lets say the goal is 1000000000000 and the current is 5000000000.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:16:26+00:00Added an answer on May 24, 2026 at 8:16 am

    Your code should look like this:

    mysql_select_db("databasename", $con);
    $result = mysql_query("select * from `dbname`.`tablename");
    if (!$result || !($row = mysql_fetch_assoc($result))) {
        echo "DB error: ".mysql_error();
        exit;
    }
    
    $goal = $row['goal'];
    $current = $row['current'];
    // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty sizeable object graph that I have serialized to a file
The situation is this: You have a Hibernate context with an object graph that
I have an XML file that encodes a directed acyclic graph (DAG) that represents
I have a Samurize config that shows a CPU usage graph similar to Task
I have a web page that displays a long line graph inside a div
I have a geometric undirected planar graph , that is a graph where each
Suppose I have two columns in a table that represents a graph, the first
Does anyone have a script for logparser that will output a graph for daily
Relating to a GP project I have a lot of auto-generated lisp snippets that
We have social graph that is later broken to clusters of high cohesion. Something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.