1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Code php : echo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="javascript" type="text/javascript" src="jquery.js"></script>
<script language="javascript" type="text/javascript" src="jquery.flot.js"></script>
</head>
<body>
<h2>Affichage Graphique</h2>
<div id="placeGraphe" style="width:800px;height:400px"></div>
<p>
<?php
$host="localhost:3308";
$login="";
$mp="";
$nom="stage";
try
{
$base=new PDO("mysql:host=localhost:3308;dbname=stage", "", "");
}
catch(Exception $e)
{
die('Erreur: ' .$e->getMessage());
}
//$rep=$base.query('select * from concept where idCpt <100');
$heure=$base->query('select heure_legale from lorient_1h_brut');
$debit=$base->query('select DUPLEIX_QTH_Debit_Traite_1h__A_ from lorient_1h_brut');
$str_date="new Array(\"0\"";
$str_deb="new Array(\"0\"";
while($data2=$heure->fetch())
{
//echo $data2['heure_legale'];
$date[]=$data2['heure_legale'];//tableau 1
$str_date.=",\"".$data2['heure_legale']."\"";
}
$heure->closeCursor();
while($data3=$debit->fetch())
{
$deb[]=$data3['DUPLEIX_QTH_Debit_Traite_1h__A_']; //tableau 2
$str_deb.=",\"".$data3['DUPLEIX_QTH_Debit_Traite_1h__A_']."\"";
}
$str_deb.=")";
$str_date.=")";
//echo "\n".$str_date."\n";
//echo "\n".$str_deb."\n";
$debit->closeCursor();
$taillex=count($date);
$tailley=count($deb);
//echo $taillex;
//echo $tailley;
?>
<script id="source" language="javascript" type="text/javascript">
(function grapher(deb, date, taillex,placeGraphe) {
//date[]; //Tableau des x du code php
//deb[]; //Tableau des y du code php
//taillex ;//taille su tableau date
//alert("salut");
for (var i = 0; i < taillex; i++)
//alert(i);
//alert(date[i]);
d1.push([date[i], deb[i]]); //push permet de créer des points à partir de coordonnées
$.plot($("#placeGraphe"), [ // plot permet d'afficher les courbes
{
data: d1,
lines: { show: true, fill: true }
}
]
});
</script>
<input type='button' value='cliquer' onclick='javascript:grapher(<?php echo $str_deb; ?>,<?php echo $str_date; ?>,<?php echo $taillex; ?>);' />
</p>
</body>
</html> |
Partager