Bonjour à tous, j'ai suivi pas mal de tuto sur le site pour débuter en PHP, MYSQL, JPGRAPH.
Mais la je bloque et je trouve pas d'exemple pour avancer.
J'ai un fichier .php dans lequel je trie mais relever de température par date avec un <input type = "date"> et un bouton <input type = "submit"> pour ensuite les afficher dans un tableau.
Et j'ai un autre fichier index1.php qui me sert pour faire un JGraph
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <html> <head> <title>Add New Record in MySQLi Database</title> <link rel = "stylesheet" type = "text/css" href = "style.css"> </head> <body> <div id = "main"> <form action = "" method = "post"> <label>Name :</label> <input type = "date" name = "date2" id = "date2" /> <br /> <br /> <input type = "submit" value ="Submit" name = "submit"/> <br /> </form> <?php if(isset($_POST["submit"])){ $servername = "localhost:3306"; $username = "root"; $password = ""; $dbname = "Projet"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); $date3 = $_POST['date2']; // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM Projettest WHERE DATE_FORMAT(Test3, '%Y-%m-%d') ='$date3' "; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { echo "<table border='1'>"; echo "<tr><td>Date :</td><td>Température :</td></tr>"; while($row = mysqli_fetch_assoc($result)) { echo "<tr><td>" . $row["Test3"]. "</td><td> " . $row["Test2"]."</td></tr>"; } echo "</table>"; echo "<iframe src=\"index1.php?\" height=\"600px\" width=\"800px\"></iframe>"; } else { echo "0 results"; } mysqli_close($conn); } ?> </body> </html>
Je fais donc appel à votre savoir.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php // content="text/plain; charset=utf-8" require_once ('src/jpgraph.php'); require_once ('src/jpgraph_line.php'); $x_axis = array(); $y_axis = array(); $b_axis = array(); $i = 0; $con = mysqli_connect("localhost", "root", "", "Projet"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con, "SELECT * FROM Projettest"); while ($row = mysqli_fetch_array($result)) { $x_axis[$i] = $row["Test1"]; $y_axis[$i] = $row["Test2"]; $b_axis[$i] = $row["Test3"]; $i++; } mysqli_close($con); // Setup the graph $graph = new Graph(800,500); $graph->SetScale("textlin"); $theme_class=new UniversalTheme; $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(false); $graph->title->Set('Filled Y-grid'); $graph->SetBox(false); $graph->SetMargin(40,20,36,163); $graph->img->SetAntiAliasing(); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false,false); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); $graph->xaxis->SetTickLabels($b_axis); $graph->xgrid->SetColor('#E3E3E3'); // Set the angle for the labels to 90 degrees $graph->xaxis->SetLabelAngle(90); // Create the first line $p1 = new LinePlot($x_axis); $graph->Add($p1); $p1->SetColor("#6495ED"); $p1->SetLegend('Line 1'); // Create the second line $p2 = new LinePlot($y_axis); $graph->Add($p2); $p2->SetColor("#B22222"); $p2->SetLegend('Line 2'); $graph->legend->SetFrameWeight(1); // Output line $graph->Stroke(); ?>
Je voudrais que ma courbe JPgraph, corresponde au valeur qui s'affiche dans le tableau losque que je fais <input type = "date"> <input type = "submit">
J'ai essayer de mettre la requête "SELECT * FROM Projettest WHERE DATE_FORMAT(Test3, '%Y-%m-%d') ='$date3'" dans JPgraph mais ca marche pas.
J'ai essayer de nombre truc sans aucun résultat, je compte donc sur votre connaissance pour m'aider ou m'orienter sur des tutos.
Cordialement.
Partager