Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpassword = '';
- $dbname = 'solarmoov' ;
- try {
- $bdd = new PDO("mysql:host=$dbhost;dbname=$dbname", "$dbuser", "$dbpassword");
- }
- catch (Exception $e) {
- die('Erreur : ' . $e->getMessage());
- }
- ?>
- <html>
- <head>
- <meta charset="utf-8">
- </head>
- <?php
- $tablemois = array('Janvier','Fevrier','Mars','Avril','Mai','Juin','Juillet','Aout','Septembre','Octobre','Novembre','Decembre');
- for ($i = 0 ; $i < 12 ; $i++)
- {
- // Insert values in bdd
- $tableensoleillement = rand (0, 100);
- $query = "INSERT INTO DATA (ensoleillement, mois) VALUES ('$tableensoleillement','".$tablemois[$i]."')";
- $bdd->query($query);
- echo $tableensoleillement.'% le mois de '.$tablemois[$i].'<br>';
- }
- // Read values in bdd
- $query = "SELECT * FROM DATA";
- $req = $bdd->query($query);
- while ($row = $req->fetch(PDO::FETCH_ASSOC))
- {
- $ensoleillement = $row['ensoleillement'];
- $mois = $row['mois'];
- echo "$ensoleillement - $mois<br>";
- }
- ?>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement