Jump to content

Gazz1982

Members
  • Posts

    83
  • Joined

  • Last visited

Everything posted by Gazz1982

  1. yes, and def = 3 to get c and def = 4 to get d
  2. I'm connecting to a mysql database and conducting a query using: <?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 $result = mysql_query("SELECT count(*) AS def1 FROM answer where def=1") or die(mysql_error()); while ($row = mysql_fetch_array ($result)) { echo"<table><tr><td>Definition 1 count=".$row["def1"]."</td></tr>\n"; } mysql_free_result ($result); this echos the result of the query then I need $a=".$row["def1"]." followed by the graph code
  3. I have created a graph using the below code. <?include("phpgraphlib.php"); $graph=new PHPGraphLib(400,300); $data=array("1"=>20, "2"=>198, "3"=>70, "4"=>90); $graph->addData($data); $graph->setTitle("Definitions"); $graph->setGradient("red", "maroon"); $graph->setBarOutlineColor("black"); $graph->setTextColor("blue"); $graph->createGraph(); // Closing connection mysql_close($link); ?> This is called from a html page using <img src="bar_graph.php" /> I have a database using mysql, how would i link this into the graph? ie from $data=array("1"=>20, "2"=>198, "3"=>70, "4"=>90); to $data=array("1"=$a, "2"=$b, "3"=>$c, "4"=>$d); in this case the $a/b/c and d would be called from a query I tried the above $data=array... but it didn't work any ideas? Gary
  4. I have created a graph using the below code. <?include("phpgraphlib.php"); $graph=new PHPGraphLib(400,300); $data=array("1"=>20, "2"=>198, "3"=>70, "4"=>90); $graph->addData($data); $graph->setTitle("Definitions"); $graph->setGradient("red", "maroon"); $graph->setBarOutlineColor("black"); $graph->setTextColor("blue"); $graph->createGraph(); // Closing connection mysql_close($link); ?> This is called from a html page using <img src="bar_graph.php" /> I have a database using mysql, how would i link this into the graph? ie from $data=array("1"=>20, "2"=>198, "3"=>70, "4"=>90); to $data=array("1"=$a, "2"=$b, "3"=>$c, "4"=>$d); in this case the $a/b/c and d would be called from a query I tried the above $data=array... but it didn't work any ideas? Gary
  5. I'm desinging a database as part of my archaeology masters in GIS I've been teaching myself apache server, php, mysql, html for the last month, its been a very steep learning curve and now i have got stuck: The database has an auto incremented ID number this is assigned on the 1st web page using the insert syntax this is then posted to the db the following pages simply update- but i dont know how to get it to select and store the id no. for that season? Also when i update the row each row gets written over therefore i want to set the primary key to the ID as well as a cookie - any ideas on how to do this? so far i have <?php setcookie(time()+3600); ?> This needs to be stored and remembered on each page so i assume i will need some kind of sql I have to tell the db that the newly created id no. is linked to the cookie so that all information from that user stays in the single row and does not over right any of the other data Thanks for you help Gary Nobles
  6. I'm desinging a database as part of my archaeology masters in GIS I've been teaching myself apache server, php, mysql, html for the last month, its been a very steep learning curve and now i have got stuck: The database has an auto incremented ID number this is assigned on the 1st web page using the insert syntax this is then posted to the db the following pages simply update- but i dont know how to get it to select and store the id no. for that season? Also when i update the row each row gets written over therefore i want to set the primary key to the ID as well as a cookie - any ideas on how to do this? so far i have <?php setcookie(time()+3600); ?> This needs to be stored and remembered on each page so i assume i will need some kind of sql I have to tell the db that the newly created id no. is linked to the cookie so that all information from that user stays in the single row and does not over right any of the other data Thanks for you help Gary Nobles
×
×
  • 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.