Jump to content

selecting multiple columns in the same table for a graph?


Gazz1982

Recommended Posts

I have columns def,distance1,distance2,distance3,distance4,distance5,distance6,distance7,distance8,elevation1,elevation2,elevation3,elevation4,

elevation5,elevation6,elevation7,elevation8,inclination1,inclination2,inclination3,inclination4,inclination5,inclination6,inclination7,

inclination8,pan1....(to 8), plan1...(to 8), comments.

 

I need to select all of the columns and arrage them in to groups so def is one group and distance another and elevation...etc all within the same graph, these would be coloured so distance1 would be the same colour as elevation1 etc...

 

heres what i have so far

 

<?php

 

// Connecting, selecting database

$link = mysql_connect('127.0.0.1', 'root', '')

  or die('Could not connect: ' . mysql_error());

//echo 'Connected successfully';

mysql_select_db('gary') or die('Could not select database');

// Performing SQL query

// Retrieve all the data from the "example" table

 

 

$sql = "SELECT def, count(*) AS def1

        FROM answer

        GROUP BY def";

       

$result = mysql_query($sql);

 

$data = array();

 

while (list($def, $def1) = mysql_fetch_row($result))

{

    $data[$def] = $def1;

}

 

 

include("phpgraphlib.php");

$graph=new PHPGraphLib(400,300);

//$data=array("1"=>$def1, "2"=>198, "3"=>70, "4"=>90);

$graph->addData($data);

$graph->setTitle("Definitions");

$graph->setGridColor("153,204,255");

$graph->setGradient("red", "maroon");

$graph->setBarOutlineColor("black");

$graph->setTextColor("blue");

$graph->createGraph();

// Closing connection

mysql_close($link);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.