|
problem with buttons |
Posted by M_jay on Jan-25-2011 13:38 |
|
I wrote a code for bubble chart inside <?php ?> tags.When I run it chart will displays as I wanted.
I want to add 12 buttons for 12 months below the chart
<input type="submit" name="Submit" value="Jan10" />
<input type="submit" name="Submit" value="Feb10" />
<input type="submit" name="Submit" value="Mar10" />
<input type="submit" name="Submit" value="Apr10" />
<input type="submit" name="Submit" value="May10" />
<input type="submit" name="Submit" value="Jun10" />
<input type="submit" name="Submit" value="Jul10" />
<input type="submit" name="Submit" value="Aug10" />
<input type="submit" name="Submit" value="Sep10" />
<input type="submit" name="Submit" value="Oct10" />
<input type="submit" name="Submit" value="Nov10" />
<input type="submit" name="Submit" value="Dec10" />
my requirement is when user clicks on the one of button chart should be changed according to the data of relevant mo
I put HTML code with 12 buttons just after my<?php ?> code but when I run it page displays only a chart no buttons.
please help me Peter
tooltip_seg.php |
---|
<?php
require_once("C:/xampp/php/ext/phpchartdir.php");
$con = mysql_connect("localhost:3306","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mygraphs", $con);
//echo $_POST['Submit'];
$month=$_POST['Submit'];
$dataX0=array(1,2,3,4,5,6,7,8,9);
$w=0;
$year='2010';
$month='April';
$v=1;
Do{
switch($v){
case 1:
$d1="Select Variable From factor Where FactorName='Economy' AND Year='2010' AND Month= 'April'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Economy' AND Year='2010' AND Month= 'April'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 2:
$d1="Select Variable From factor Where FactorName='HealthyLifestyle' AND Year='2010' AND Month= 'April'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='HealthyLifestyle' AND Year='2010' AND Month= 'April'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 3:
$d1="Select Variable From factor Where FactorName='Urban Growth' AND Year='2010' AND Month= 'April'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Urban Growth' AND Year='2010' AND Month= 'April'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 4:
$d1="Select Variable From factor Where FactorName='Transport' AND Year='2010' AND Month= 'April'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Transport' AND Year='2010' AND Month= 'April'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 5:
$d1="Select Variable From factor Where FactorName='Crime & Safety' AND Year='2010' AND Month= 'April'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Crime & Safety' AND Year='2010' AND Month= 'April'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 6:
$d1="Select Variable From factor Where FactorName='Commiunity ' AND Year='2010' AND Month= 'April'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Commiunity ' AND Year='2010' AND Month= 'April'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 7:
$d1="Select Variable From factor Where FactorName='Environment' AND Year='2010' AND Month= 'April'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Environment' AND Year='2010' AND Month= 'April'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 8:
$d1="Select Variable From factor Where FactorName='Education' AND Year='2010' AND Month= 'April'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Education' AND Year='2010' AND Month= 'April'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 9:
$d1="Select Variable From factor Where FactorName='Health' AND Year='2010' AND Month= 'April'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Health' AND Year='2010' AND Month= 'April'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
} //end sw
$sum = 0;
while($row = mysql_fetch_array($rd1))
{
$f = $row['Variable'] ;
//echo $f;
switch($f){
Case q2_1:
$d2 = mysql_query("Select AVG(Q2_1) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
// echo $d2;
break;
Case q2_2:
$d2 = mysql_query("Select AVG(Q2_2) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
// echo $d2;
break;
Case q2_3:
$d2=mysql_query("Select AVG(Q2_3) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
//echo $d2;
break;
Case q2_4:
$d2=mysql_query("Select AVG(Q2_4) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_5:
$d2=mysql_query("Select AVG(Q2_5) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_6:
$d2=mysql_query("Select AVG(Q2_6) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_7:
$d2=mysql_query("Select AVG(Q2_7) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_8:
$d2=mysql_query("Select AVG(Q2_8) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_9:
$d2=mysql_query("Select AVG(Q2_9) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_10:
$d2=mysql_query("Select AVG(Q2_10) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_11:
$d2=mysql_query("Select AVG(Q2_11) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_12:
$d2=mysql_query("Select AVG(Q2_12) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_13:
$d2=mysql_query("Select AVG(Q2_13) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_14:
$d2=mysql_query("Select AVG(Q2_14) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_15:
$d2=mysql_query("Select AVG(Q2_15) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_16:
$d2=mysql_query("Select AVG(Q2_16) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_17:
$d2=mysql_query("Select AVG(Q2_17) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_18:
$d2=mysql_query("Select AVG(Q2_18) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_19:
$d2=mysql_query("Select AVG(Q2_19) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_20:
$d2=mysql_query("Select AVG(Q2_20) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_21:
$d2=mysql_query("Select AVG(Q2_21) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_22:
$d2=mysql_query("Select AVG(Q2_22) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_23:
$d2=mysql_query("Select AVG(Q2_23) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_24:
$d2=mysql_query("Select AVG(Q2_24) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_25:
$d2=mysql_query("Select AVG(Q2_25) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_26:
$d2=mysql_query("Select AVG(Q2_26) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_27:
$d2=mysql_query("Select AVG(Q2_27) as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_28:
$d2=mysql_query("Select AVG(Q2_28)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_29:
$d2=mysql_query("Select AVG(Q2_29)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_30:
$d2=mysql_query("Select AVG(Q2_30)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
Case q2_31:
$d2=mysql_query("Select AVG(Q2_31)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_32:
$d2=mysql_query("Select AVG(Q2_32)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_33:
$d2=mysql_query("Select AVG(Q2_33)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_34:
$d2=mysql_query("Select AVG(Q2_34)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
break;
Case q2_35:
$d2=mysql_query("Select AVG(Q2_35)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_36:
$d2=mysql_query("Select AVG(Q2_36)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_37:
$d2=mysql_query("Select AVG(Q2_37)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_38:
$d2=mysql_query("Select AVG(Q2_38)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_39:
$d2=mysql_query("Select AVG(Q2_39)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_40:
$d2=mysql_query("Select AVG(Q2_40)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_41:
$d2=mysql_query("Select AVG(Q2_41)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_42:
$d2=mysql_query("Select AVG(Q2_42)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_43:
$d2=mysql_query("Select AVG(Q2_43)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_44:
$d2=mysql_query("Select AVG(Q2_44)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_45:
$d2=mysql_query("Select AVG(Q2_45)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_46:
$d2=mysql_query("Select AVG(Q2_46)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_47:
$d2=mysql_query("Select AVG(Q2_47)as a From var_ratings Where Year='2010' AND Month= 'April'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
}//switch
$sum=$n+$sum;
} //while
// echo "<br/>";
// echo $sum;
// echo "<br/>";
$g=$sum/$ar_length;
// echo $g;
//$e1=$g;
if($w==0){
$e1=$g;
$ar[]=$e1;
}
elseif($w==1){
$e2=$g;
$ar[]=$e2;
}
elseif($w==2){
$e3=$g;
$ar[]=$e3;
}
elseif($w==3){
$e4=$g;
$ar[]=$e4;
}
elseif($w==4){
$e5=$g;
$ar[]=$e5;
}
elseif($w==5){
$e6=$g;
$ar[]=$e6;
}
elseif($w==6){
$e7=$g;
$ar[]=$e7;
}
elseif($w==7){
$e8=$g;
$ar[]=$e8;
}
elseif($w==8){
$e9=$g;
$ar[]=$e9;
}
$v++;
$w++;
}//do
while($v<10);
// echo "aqwsedrf";
// echo $ar[0];
// echo $ar[1];
// echo $ar[2];
// echo $ar[3];
// echo $ar[4];
// echo $ar[5];
// echo $ar[6];
// echo $ar[7];
// echo $ar[8];
//echo "end of files";
$di1=mysql_query("Select Importance From importance_of_factors Where Factor='Economy' AND Year='2010' AND Month= 'April' ");
$di2=mysql_query("Select Importance From importance_of_factors Where Factor='HealthyLifestyle' AND Year='2010' AND Month= 'April' ");
$di3=mysql_query("Select Importance From importance_of_factors Where Factor='Urban Growth' AND Year='2010' AND Month= 'April' ");
$di4=mysql_query("Select Importance From importance_of_factors Where Factor='Transport' AND Year='2010' AND Month= 'April' ");
$di5=mysql_query("Select Importance From importance_of_factors Where Factor='Crime & Safety' AND Year='2010' AND Month= 'April' ");
$di6=mysql_query("Select Importance From importance_of_factors Where Factor='Commiunity' AND Year='2010' AND Month= 'April' ");
$di7=mysql_query("Select Importance From importance_of_factors Where Factor='Environment' AND Year='2010' AND Month= 'April' ");
$di8=mysql_query("Select Importance From importance_of_factors Where Factor='Education' AND Year='2010' AND Month= 'April' ");
$di9=mysql_query("Select Importance From importance_of_factors Where Factor='Health' AND Year='2010' AND Month= 'April' ");
$ar2=array($di1,$di2,$di3,$di4,$di5,$di6,$di7,$di8,$di9);
$labels = array("","<*color=ff0000*>Economy","<*color=0x008000*>HealthyLifestyle", "<*color=0x0000FF*>Urban Growth", "<*color=daa520*>Transport","<*color= 0xEE82EE*>Crime & Safety","<*color=0x00FFFF*>Commiunity","<*color=cd853f*>Environment","<*color=0xcccccc*>Education","<*color=8b7d6b*>Health","");
/* $labels = array("0","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>", "<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>", "<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","");*/
//scatterLayerObj->addExtraField($labels);
//scatterLayerObj->setDataLabelFormat("{field0}");
$colors = array(0x008000, 0xeebb22, 0xcccccc, 0xcc88ff,0x66aaee, 0xeebb22, 0xcccccc, 0xcc88ff,0x66aaee);
# Create a XYChart object of size 450 x 420 pixels
// $c = new XYChart(450, 420);
$c = new XYChart(750, 720);
# Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey border
# (0xc0c0c0). Turn on both horizontal and vertical grid lines with light grey color # (0xc0c0c0)
$c->setPlotArea(55, 65, 700, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1);
# Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12 pts # Times Bold Italic font. Set the background and border color to Transparent.
$legendObj = $c->addLegend(50, 30, false, "timesbi.ttf", 12);
$legendObj->setBackground(Transparent);
# Add a title to the chart using 18 pts Times Bold Itatic font.
$c->addTitle("Segmentation (by factor)", "timesbi.ttf", 18);
# Add a title to the y axis using 12 pts Arial Bold Italic font
$c->yAxis->setTitle("Satisfaction (Scale 1 Very bad - 5 Very good)", "arialbi.ttf", 12);
# Add a title to the x axis using 12 pts Arial Bold Italic font
$c->xAxis->setLabels($labels);
$c->xAxis->setLabelStyle("arialbd.ttf", 8);
// $c->xAxis->setTitle("Range (miles)", "arialbi.ttf", 12);
# Set the axes line width to 3 pixels
$c->xAxis->setWidth(3);
$c->yAxis->setWidth(3);
for ($i = 0; $i < count($ar); ++$i) {
$scatterLayerObj = $c->addScatterLayer(array($dataX0[$i]), array($ar[$i]), $color[$i], GlassSphereShape, 7);
$scatterLayerObj->setSymbolScale(array($ar2[$i]));
}
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form action="tooltip_seg.php" method ="post">
<table>
<tr>
<td align="right">
<input type="button" value="Total" onClick="drawCircle()"/></A>
</td></tr>
<tr>
<td align="right">
<A HREF="Graph1.php"><input type="button" value="Segment 1" /></A>
</td>
</tr>
<tr>
<td align="right">
<A HREF="Graph1.php"><input type="button" value="Segment 2" /></A>
</td>
</tr>
<tr><td>
<IMG SRC="Segment_Factor.php">
</td></tr>
<tr><td>
<input type="submit" name="Submit" value="Jan10" />
<input type="submit" name="Submit" value="Feb10" />
<input type="submit" name="Submit" value="Mar10" />
<input type="submit" name="Submit" value="Apr10" />
<input type="submit" name="Submit" value="May10" />
<input type="submit" name="Submit" value="Jun10" />
<input type="submit" name="Submit" value="Jul10" />
<input type="submit" name="Submit" value="Aug10" />
<input type="submit" name="Submit" value="Sep10" />
<input type="submit" name="Submit" value="Oct10" />
<input type="submit" name="Submit" value="Nov10" />
<input type="submit" name="Submit" value="Dec10" />
</td>
</tr>
</table>
</form>
</body>
</html>
|
| |
Re: problem with buttons |
Posted by Peter Kwan on Jan-25-2011 16:48 |
|
Hi M_jay,
Note that you cannot put HTML in an image. For example, you cannot use a text editor to open a JPG image file, and put HTML in it. Also, you cannot put an image in HTML. You can only put an <IMG> tag in HTML to reference the image.
So for your case, your HTML should be in another file:
<HTML><BODY>
<IMG SRC="tooltip_seg.php?Submit=<?php echo isset($_POST['Submit'])?$_POST['Submit']:'Jan10' ?>">
.... put your buttons here ....
</BODY></HTML>
Also, whereas you can use POST in HTML, you can only use GET in images. As far as I know, there is no browser that supports POST in images.
Hope this can help.
Regards
Peter Kwan |
Re: problem with buttons |
Posted by M_jay on Jan-27-2011 01:41 |
|
hi Peter,
My requirement is When user clicks on one of these button Form1.php page displays
graph according to the data of relevant month.
<HTML>
<head>
</head>
<body>
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'January'?>"/>
<input type="submit" name="Submit" value="January" />
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'February'?>"/>
<input type="submit" name="Submit" value="February" />
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'March'?>"/>
<input type="submit" name="Submit" value="March" />
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'April'?>"/>
<input type="submit" name="Submit" value="April" />
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'May'?>"/>
<input type="submit" name="Submit" value="May" />
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'June'?>"/>
<input type="submit" name="Submit" value="June" />
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'July'?>"/>
<input type="submit" name="Submit" value="July" />
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'August'?>"/>
<input type="submit" name="Submit" value="August" />
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'September'?>"/>
<input type="submit" name="Submit" value="September" />
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'October'?>"/>
<input type="submit" name="Submit" value="October" />
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'November'?>"/>
<input type="submit" name="Submit" value="November" />
<IMG SRC="Form1.php?Submit=<?php echo isset($_POST['Submit'])?
$_POST['Submit']:'December'?>"/>
<input type="submit" name="Submit" value="December" />
</body>
</html>
I want to know how should I use $_POST['Submit'] variable value inside my Form1.php file
I want to assign value of $_POST['Submit'] variable in to '$month' variable on Form1.php
Thank you
Form1.php |
---|
<?php
require_once("G:/xampp/php/ext/phpchartdir.php");
$con = mysql_connect("localhost:3306","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mygraphs", $con);
$month = $_POST['Submit'];
$dataX0=array(1,2,3,4,5,6,7,8,9);
$w=0;
$year='2010';
// $month='$month';
$v=1;
Do{
switch($v){
case 1:
$d1="Select Variable From factor Where FactorName='Economy' AND Year='2010' AND Month= '$month'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Economy' AND Year='2010' AND Month= '$month'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 2:
$d1="Select Variable From factor Where FactorName='HealthyLifestyle' AND Year='2010' AND Month= '$month'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='HealthyLifestyle' AND Year='2010' AND Month= '$month'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 3:
$d1="Select Variable From factor Where FactorName='Urban Growth' AND Year='2010' AND Month= '$month'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Urban Growth' AND Year='2010' AND Month= '$month'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 4:
$d1="Select Variable From factor Where FactorName='Transport' AND Year='2010' AND Month= '$month'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Transport' AND Year='2010' AND Month= '$month'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 5:
$d1="Select Variable From factor Where FactorName='Crime & Safety' AND Year='2010' AND Month= '$month'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Crime & Safety' AND Year='2010' AND Month= '$month'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 6:
$d1="Select Variable From factor Where FactorName='Commiunity ' AND Year='2010' AND Month= '$month'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Commiunity ' AND Year='2010' AND Month= '$month'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 7:
$d1="Select Variable From factor Where FactorName='Environment' AND Year='2010' AND Month= '$month'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Environment' AND Year='2010' AND Month= '$month'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 8:
$d1="Select Variable From factor Where FactorName='Education' AND Year='2010' AND Month= '$month'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Education' AND Year='2010' AND Month= '$month'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
case 9:
$d1="Select Variable From factor Where FactorName='Health' AND Year='2010' AND Month= '$month'";
$rd1 = mysql_query($d1);
$dd1="Select COUNT(Variable) as c From factor Where FactorName='Health' AND Year='2010' AND Month= '$month'";
$rdd1 = mysql_query($dd1);
$row = mysql_fetch_array($rdd1);
$ar_length =$row['c'];
// echo "cccccc" ;
// echo $ar_length;
break;
} //end sw
$sum = 0;
while($row = mysql_fetch_array($rd1))
{
$f = $row['Variable'] ;
//echo $f;
switch($f){
Case q2_1:
$d2 = mysql_query("Select AVG(Q2_1) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
// echo $d2;
break;
Case q2_2:
$d2 = mysql_query("Select AVG(Q2_2) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
// echo $d2;
break;
Case q2_3:
$d2=mysql_query("Select AVG(Q2_3) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
//echo $d2;
break;
Case q2_4:
$d2=mysql_query("Select AVG(Q2_4) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_5:
$d2=mysql_query("Select AVG(Q2_5) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_6:
$d2=mysql_query("Select AVG(Q2_6) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_7:
$d2=mysql_query("Select AVG(Q2_7) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_8:
$d2=mysql_query("Select AVG(Q2_8) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_9:
$d2=mysql_query("Select AVG(Q2_9) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_10:
$d2=mysql_query("Select AVG(Q2_10) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_11:
$d2=mysql_query("Select AVG(Q2_11) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_12:
$d2=mysql_query("Select AVG(Q2_12) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_13:
$d2=mysql_query("Select AVG(Q2_13) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_14:
$d2=mysql_query("Select AVG(Q2_14) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_15:
$d2=mysql_query("Select AVG(Q2_15) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_16:
$d2=mysql_query("Select AVG(Q2_16) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_17:
$d2=mysql_query("Select AVG(Q2_17) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_18:
$d2=mysql_query("Select AVG(Q2_18) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_19:
$d2=mysql_query("Select AVG(Q2_19) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_20:
$d2=mysql_query("Select AVG(Q2_20) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_21:
$d2=mysql_query("Select AVG(Q2_21) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_22:
$d2=mysql_query("Select AVG(Q2_22) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_23:
$d2=mysql_query("Select AVG(Q2_23) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_24:
$d2=mysql_query("Select AVG(Q2_24) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_25:
$d2=mysql_query("Select AVG(Q2_25) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_26:
$d2=mysql_query("Select AVG(Q2_26) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_27:
$d2=mysql_query("Select AVG(Q2_27) as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_28:
$d2=mysql_query("Select AVG(Q2_28)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_29:
$d2=mysql_query("Select AVG(Q2_29)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_30:
$d2=mysql_query("Select AVG(Q2_30)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
Case q2_31:
$d2=mysql_query("Select AVG(Q2_31)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_32:
$d2=mysql_query("Select AVG(Q2_32)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_33:
$d2=mysql_query("Select AVG(Q2_33)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_34:
$d2=mysql_query("Select AVG(Q2_34)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
break;
Case q2_35:
$d2=mysql_query("Select AVG(Q2_35)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_36:
$d2=mysql_query("Select AVG(Q2_36)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_37:
$d2=mysql_query("Select AVG(Q2_37)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_38:
$d2=mysql_query("Select AVG(Q2_38)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_39:
$d2=mysql_query("Select AVG(Q2_39)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_40:
$d2=mysql_query("Select AVG(Q2_40)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_41:
$d2=mysql_query("Select AVG(Q2_41)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_42:
$d2=mysql_query("Select AVG(Q2_42)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_43:
$d2=mysql_query("Select AVG(Q2_43)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_44:
$d2=mysql_query("Select AVG(Q2_44)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_45:
$d2=mysql_query("Select AVG(Q2_45)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_46:
$d2=mysql_query("Select AVG(Q2_46)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
Case q2_47:
$d2=mysql_query("Select AVG(Q2_47)as a From var_ratings Where Year='2010' AND Month= '$month'");
$row = mysql_fetch_array($d2);
$n=$row['a'];
// echo $n;
break;
}//switch
$sum=$n+$sum;
} //while
// echo "<br/>";
// echo $sum;
// echo "<br/>";
$g=$sum/$ar_length;
// echo $g;
//$e1=$g;
if($w==0){
$e1=$g;
$ar[]=$e1;
}
elseif($w==1){
$e2=$g;
$ar[]=$e2;
}
elseif($w==2){
$e3=$g;
$ar[]=$e3;
}
elseif($w==3){
$e4=$g;
$ar[]=$e4;
}
elseif($w==4){
$e5=$g;
$ar[]=$e5;
}
elseif($w==5){
$e6=$g;
$ar[]=$e6;
}
elseif($w==6){
$e7=$g;
$ar[]=$e7;
}
elseif($w==7){
$e8=$g;
$ar[]=$e8;
}
elseif($w==8){
$e9=$g;
$ar[]=$e9;
}
$v++;
$w++;
}//do
while($v<10);
// echo "aqwsedrf";
// echo $ar[0];
// echo $ar[1];
// echo $ar[2];
// echo $ar[3];
// echo $ar[4];
// echo $ar[5];
// echo $ar[6];
// echo $ar[7];
// echo $ar[8];
//echo "end of files";
$di1=mysql_query("Select Importance From importance_of_factors Where Factor='Economy' AND Year='2010' AND Month= '$month' ");
$di2=mysql_query("Select Importance From importance_of_factors Where Factor='HealthyLifestyle' AND Year='2010' AND Month= '$month' ");
$di3=mysql_query("Select Importance From importance_of_factors Where Factor='Urban Growth' AND Year='2010' AND Month= '$month' ");
$di4=mysql_query("Select Importance From importance_of_factors Where Factor='Transport' AND Year='2010' AND Month= '$month' ");
$di5=mysql_query("Select Importance From importance_of_factors Where Factor='Crime & Safety' AND Year='2010' AND Month= '$month' ");
$di6=mysql_query("Select Importance From importance_of_factors Where Factor='Commiunity' AND Year='2010' AND Month= '$month' ");
$di7=mysql_query("Select Importance From importance_of_factors Where Factor='Environment' AND Year='2010' AND Month= '$month' ");
$di8=mysql_query("Select Importance From importance_of_factors Where Factor='Education' AND Year='2010' AND Month= '$month' ");
$di9=mysql_query("Select Importance From importance_of_factors Where Factor='Health' AND Year='2010' AND Month= '$month' ");
$ar2=array($di1,$di2,$di3,$di4,$di5,$di6,$di7,$di8,$di9);
$labels = array("","<*color=ff0000*>Economy","<*color=0x008000*>HealthyLifestyle", "<*color=0x0000FF*>Urban Growth", "<*color=daa520*>Transport","<*color= 0xEE82EE*>Crime & Safety","<*color=0x00FFFF*>Commiunity","<*color=cd853f*>Environment","<*color=0xcccccc*>Education","<*color=8b7d6b*>Health","");
/* $labels = array("0","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>", "<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>", "<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","<*img=C:/xampp/htdocs/MYGRAPHS/img/img1.png*>","");*/
//scatterLayerObj->addExtraField($labels);
//scatterLayerObj->setDataLabelFormat("{field0}");
$colors = array(0x008000, 0xeebb22, 0xcccccc, 0xcc88ff,0x66aaee, 0xeebb22, 0xcccccc, 0xcc88ff,0x66aaee);
# Create a XYChart object of size 450 x 420 pixels
// $c = new XYChart(450, 420);
$c = new XYChart(750, 720);
# Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey border
# (0xc0c0c0). Turn on both horizontal and vertical grid lines with light grey color # (0xc0c0c0)
$c->setPlotArea(55, 65, 700, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1);
# Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12 pts # Times Bold Italic font. Set the background and border color to Transparent.
$legendObj = $c->addLegend(50, 30, false, "timesbi.ttf", 12);
$legendObj->setBackground(Transparent);
# Add a title to the chart using 18 pts Times Bold Itatic font.
$c->addTitle("Segmentation (by factor)", "timesbi.ttf", 18);
# Add a title to the y axis using 12 pts Arial Bold Italic font
$c->yAxis->setTitle("Satisfaction (Scale 1 Very bad - 5 Very good)", "arialbi.ttf", 12);
# Add a title to the x axis using 12 pts Arial Bold Italic font
$c->xAxis->setLabels($labels);
$c->xAxis->setLabelStyle("arialbd.ttf", 8);
// $c->xAxis->setTitle("Range (miles)", "arialbi.ttf", 12);
# Set the axes line width to 3 pixels
$c->xAxis->setWidth(3);
$c->yAxis->setWidth(3);
for ($i = 0; $i < count($ar); ++$i) {
$scatterLayerObj = $c->addScatterLayer(array($dataX0[$i]), array($ar[$i]), $color[$i], GlassSphereShape, 7);
$scatterLayerObj->setSymbolScale(array($ar2[$i]));
}
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>
|
| |
Re: problem with buttons |
Posted by Peter Kwan on Jan-27-2011 11:17 |
|
Hi M_jay,
If you want to show something in Form1.php, please POST to Form1.php. For details on how to write HTML to post to Form1.php, please refer to your HTML documentation. (This part is not unrelated to ChartDirector at all, but I will provide an example anyway. Please refer to your HTML documentation in case you have any issues.)
<html><body>
<form action="Form1.php" method="POST">
<input type="submit" name="Submit" value="January" />
<input type="submit" name="Submit" value="February" />
.....
</form>
</body></html>
In your Form1.php, you want to display a chart, so you may simply write code to display a chart based on the "Submit" variable. It is like:
<html><body>
<img src="createMyChart.php?xxx=<?php $_POST['Submit'] ?>">
</body></html>
Again, the above is not related to ChartDirector. You can see there is absolutely no charting code, only a few lines of simple HTML/PHP code. If you are not sure what the above code is doing, please refer to your HTML/PHP documentation.
In your createMyChart.php, please put the charting code there. As you can see in the above code, the month is in the GET variable xxx. In other words, in your createMyChart.php, the month can be retreived as:
$month = $_GET["xxx"];
Hope this can help.
Regards
Peter Kwan |
|