-
Compteur de contenus
5 -
Inscription
-
Dernière visite
Visiteurs récents du profil
Le bloc de visiteurs récents est désactivé et il n’est pas visible pour les autres utilisateurs.
noursane's Achievements

Cirrus (1/24)
-
Bonsoir à tous, je voulais juste savoir comment lire des données spécifique d'un code xml . Merci ,
-
merci pour votre réponse.
-
Bonsoir, je réalise un courbe dynamique à partir MySQL avec librairie www.highcharts.com , mon base de donnée contient le température sur 5 jours(heure par heure) ,les données insérer dans ma base à partir d'un fichier XML de l'URL: http://api.tameteo.com/index.php?api_lang=fr&localidad=8952&affiliate_id=wf7toya165cq&v=2&h=1 fichier d'nsertion: insertion.php <?php $host="localhost"; $base="bd"; $login="root"; $pwd=""; $bdd=mysqli_connect($host, $login, $pwd); mysqli_select_db($bdd,$base) ; $file='http://api.tameteo.com/index.php?api_lang=fr&localidad=8952&affiliate_id=wf7toya165cq&v=2&h=1'; $xml =simplexml_load_file($file); $sql1='Delete from heurej '; if ( ! mysqli_query($bdd, $sql1)) echo 'Erreur : '.mysqli_error($bdd).'<br>'.$sql1.'<br>'; foreach($xml->location as $location) { foreach($location->day as $day) { $name=$day['name']; $symbol=$day->symbol['value']; $tempmin=$day->tempmin['value']; $tempmax=$day->tempmax['value']; $wind=$day->wind['value']; $rain=$day->rain['value']; $humidity=$day->humidity['value']; $pressure=$day->pressure['value']; $snow=$day->snowline['value']; $sunrise=$day->sun['in']; $sunriseo=$day->sun['out']; $milieu=$day->sun['mid']; $moonrise=$day->moon['in']; $moonriseo=$day->moon['out']; $lumiere=$day->moon['lumi']; $descreption=$day->moon['desc']; $info=$day->local_info['local_time']; $heure=$day->heure['value']; $sql='INSERT INTO heurej (nom,heure,temperature,vent,pluie,humidite,pression,ligneneige,nuages,windchill) values("'.$name.'","'.$heure. '","'.$temperature.'","'.$vent.'","'.$pluie.'","'.$humidite.'","'.$pression.'","'.$snowline.'","'.$clouds.'","'.$windchill.'")'; if ( ! mysqli_query($bdd, $sql)) echo 'Erreur : '.mysqli_error($bdd).'<br>'.$sql.'<br>'; } } ?> structure de base de donnée après l'insertion: fichier temperature.php pour afficher le valeur des température à partir de la structure de base de donnée ou dessus. temperature.php <?php // on se connecte à notre base $base = mysql_connect ('localhost', 'root', ''); mysql_select_db ('bd', $base) ; ?> <?php $return=array(); $sql = 'SELECT temperature FROM heurej order by nom'; // on lance la requête (mysql_query) et on impose un message d'erreur si la requête ne se passe pas bien (or die) $req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error()); while ($data = mysql_fetch_array($req)) { $return[0][] = $data['temperature']; } $result = array( 0 => array('name' => 'temperature', 'data' => $return[0]), ); echo json_encode($result, JSON_NUMERIC_CHECK); ?> fichier temperaturephp.php pour afficher le courbe de temperature. temperaturephp.php: <html> <body> </div> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> $(function () { var chart; $(document).ready(function() { $.getJSON("temperaturephp.php", function(json) { chart = new Highcharts.Chart({ chart: { renderTo: 'container',52 type: 'line', marginRight: 130, marginBottom: 25 }, title: { text: "température(Heure Par Heure) ", x: -20 //center }, subtitle: { text: '', x: -20 }, xAxis: { categories: ['1:00', '2:00', '3:00', '4:00', '5:00', '6:00', '7:00', '8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '20:00', '21:00', '22:00', '23:00', '24:00'] }, yAxis: { title: { text: 'Temperature' }, plotLines: [{ value: 0, width: 1, color: '#ff0022' }] }, tooltip: { formatter: function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y; } }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', x: -10, y: 200, borderWidth: 0 }, series: json }); }); }); }); </script> <script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div> </body> </html> résultats: mon besoin: à partir de l'exemple ou dessus de structure de base de donnée réalise un courbe de température de 5 jours(voir le nom de 5 jours sur l'axe x) avec le 24 de heures de chaque jour . le chose incomplète dans l'exemple de figure que afficher ou dessus c'est le nom de jours comme ça sur l'axe x: Dimanche 1:00 2:00 3:00 ............Lundi 1:00 2:00........... Mardi 1:00 2:00 3:00 4:00 ......................Mercredi 1:00 2:00 3:00.............jeudi 1:00 2:00 3:00......... Qui a un exemple qui peut me donner mon besoin . Merci d'avance,
-
Bonsoir, je réalise un courbe dynamique à partir MySQL avec librairie www.highcharts.com , mon base de donnée contient le température sur 5 jours(heure par heure) ,les données insérer dans ma base à partir d'un fichier XML mais sur l'axe x donner juste le nom de jours ou les heures (ne donner pas les deux même temps). xAxis: { categories: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'] }, ou xAxis: { categories: ['1:00', '2:00', '3:00', '4:00', '5:00', '6:00', '7:00', '8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '20:00', '21:00', '22:00', '23:00', '24:00'] }, voici la structure de base de donnée: résultats: mon besoin: à partir de l'exemple ce dessus de structure base de donnée réalise un courbe(juste pour le vendredi heure par heure) Merci, structure de base de donnees.docx
-
Salut, avec le L'URL:http://'http://api.tameteo.com/index.php?api_lang=fr&localidad=8963&affiliate_id=wf7toya165cq&v=2&h=1' (le mise à jour sera réalise automatiquement à chaque jour supprime un jour avant et ajoute un jour après)et le code que écrit par jackT est correcte , Est-il trouve un possibilité d'exemple de code(html dans php) donner le résultat ce dessous(afficher dans un site). nom symbol tempmin tempmax wind rain humidity pressure snowline Dimanche 3 12 22 29 0 72 1019 3200 nom symbol tempmin tempmax wind rain humidity pressure snowline Lundi 2 9 22 29 0 66 1020 2900 nom symbol tempmin tempmax wind rain humidity pressure snowline Mardi 1 10 20 28 0 66 1025 2700 nom symbol tempmin tempmax wind rain humidity pressure snowline Mercredi 1 8 20 18 0 73 1026 2000 nom symbol tempmin tempmax wind rain humidity pressure snowline jeudi 1 9 21 17 0 69 1028 2300 (un table comme ça pour chaque jour) Dimanche 1 :00 2 :00 3 :00 4 :00 5 :00 6 :00 7 :00 24 :00 temp 15 symbol 3 wind 29 rain 0 humidity 87 pressure 1021 clouds 39% snowline 3500 windchill 15 Qui a une solution? Merci ,
-
Salut, Merci jackT pour votre réponse . ton code est fonctionne chez moi encore , mais mon besoin de voir comme ça(les tables) dans ma base de donnée selon les données dans le lien: http://api.tameteo.com/index.php?api_lang=fr&localidad=8963&affiliate_id=wf7toya165cq&v=2&h=1 nom table: jour1 nom symbol tempmin tempmax wind rain humidity pressure snowline Dimanche 3 12 22 29 0 72 1019 3200 nom table: jour2 nom symbol tempmin tempmax wind rain humidity pressure snowline Lundi 2 9 22 29 0 66 1020 2900 nom table:jour3 nom symbol tempmin tempmax wind rain humidity pressure snowline Mardi 1 10 20 28 0 66 1025 2700 nom table: jour4 nom symbol tempmin tempmax wind rain humidity pressure snowline Mercredi 1 8 20 18 0 73 1026 2000 nom table: jour5 nom symbol tempmin tempmax wind rain humidity pressure snowline jeudi 1 9 21 17 0 69 1028 2300 nom table: hour(un table comme ça pour chaque jour) Dimanche 1 :00 2 :00 3 :00 4 :00 5 :00 6 :00 7 :00 24 :00 temp 15 symbol 3 wind 29 rain 0 humidity 87 pressure 1021 clouds 39% snowline 3500 windchill 15 Est-il trouve un possibilite d'exemple de code donner le résultat ce dessus Merci d'avance.
-
Salut ! mon objective est crée un site météo pour ma ville. je trouve quelque difficulté je crée quelque exemple de code php pour lire l'url de fichier xml: http://api.tameteo.com/index.php?api_lang=fr&localidad=8963&affiliate_id=wf7toya165cq&v=2&h=1 Achaque fois Aucun erreur dans le code php mais aucun insertion dans la base de données voici l'affichage: voici l'exemple des code php: exemple1: <?php try { $bdd = new PDO('mysql:host=localhost; dbname=pf; charset=utf8', 'root', ''); $url='http://api.tameteo.com/index.php?api_lang=fr&localidad=8963&affiliate_id=wf7toya165cq&v=2&h=1'; $xml =simplexml_load_file($url); foreach($xml->location as $location) { foreach($location->day as $day) { echo($day[0]['name'])."</br>"; foreach($day->symbol as $symbol) { echo($symbol[0]['value'])."</br>"; } foreach($day->tempmin as $tempmin) { echo($tempmin[0]['value'])."</br>"; } foreach($day->tempmax as $tempmax) { echo($tempmax[0]['value'])."</br>"; } foreach($day->wind as $wind) { echo($wind[0]['value'])."</br>"; } foreach($day->rain as $rain) { echo($rain[0]['value'])."</br>"; } foreach($day->humidity as $humidity) { echo($humidity[0]['value'])."</br>"; } foreach($day->pressure as $pressure) { echo($pressure[0]['value'])."</br>"; } foreach($day->snowline as $snow) { echo($snow[0]['value'])."</br>"; } foreach($day->sun as $sun) { echo($sun[0]['value'])."</br>"; } foreach($day->moon as $moon) { echo($moon[0]['value'])."</br>"; } foreach($day->local_info as $info) { echo($info[0]['value'])."</br>"; } $sql=$bdd->prepare('INSERT INTO jour1(nomj1,symbolej1,tempminj1,tempmaxj1,windj1,windgustsj1,rainj1,humidityj1,pressurej1,snowlinej1,sun,moonj1, localinfoj1,"") values("'.$day[0]['name'].'","'.$symbol[0]['value'].'","'.$tempmin[0]['value'].'",,"'.$tempmax[0]['value'].'",,"'.$wind[0]['value'].'","","'.$rain[0]['value'].'",,"'.$humidity[0]['value'].'",,"'.$pressure[0]['value'].'",,"'.$snow[0]['value'].'",,"'.$sun[0]['value'].'",,"'.$moon[0]['value'].'",,"'.$info[0]['value'].'",,"",)'); $sql->execute(); } } } catch (Exception $e) { die('Erreur : ' . $e->getMessage()); } ?> exemple2: <?php try { $bdd = new PDO('mysql:host=localhost; dbname=bd; charset=utf8', 'root', ''); $url='http://api.tameteo.com/index.php?api_lang=fr&localidad=8963&affiliate_id=wf7toya165cq&v=2&h=1'; $xml =simplexml_load_file($url); $tableau=array(14); foreach($xml->location as $location){ $city=$location['city']."<br />"; $nom=$location->day['name']; $symb=$location->day->symbol['value']; $tempmin=$location->day->tempmin['value']; $tempmax=$location->day->tempmax['value']; $wind=$location->day->wind['value']; //$windgust=$location->day->windgusts['value']; $rain=$location->day->rain['value']; $humidite=$location->day->humidity['value']; $pressur=$location->day->pressure['value']; $snowline=$location->day->snowline['value']; $sun=$location->day->sun['value']; $moon=$location->day->moon['value']; $info=$location->day->local_info['value']; $hour=$location->day->hour['value']; /* $city=$xml->location['city']."<br />"; $nom=$xml->location->day['name']; $symb=$xml->location->day->symbol['value']; $tempmin=$xml->location->day->tempmin['value']; $tempmax=$xml->location->day->tempmax['value']; $wind=$xml->location->day->wind['value']; $windgust=$xml->location->day->wind_gusts['value']; $rain=$xml->location->day->rain['value']; $humidite=$xml->location->day->humidity['value']; $pressur=$xml->location->day->pressure['value']; $snowline=$xml->location->day->snowline['value']; $sun=$xml->location->day->sun['value']; $moon=$xml->location->day->moon['value']; $info=$xml->location->day->local_info['value']; $hour=$xml->location->day->hour['value'];*/ $sql=$bdd->prepare('INSERT INTO jour(nom,symbole,tempmin,tempmax,wind,wind-gusts,rain,humidite,pressure,snowline,sun,moon,localinfo,hour) values(:nom, :symbol, :tempmin, :tempmax, :wind, "", :rain, :humidite, :pressure, :snowline, :sun, :moon, :info, :hour,)'); $sql->execute(array ('nom'=>$nom, 'symbol' => $symb, 'tempmin' => $tempmin, 'tempmax' => $tempmax, 'wind' => $wind, //'windgusts' => $tableau[5], 'rain' => $rain, 'humidite' => $humidite, 'pressure' => $pressur, 'snowline' => $snowline, 'sun' => $sun, 'moon' => $moon, 'info' => $info, 'hour' => $hour, )); } echo 'le chargement de fichier xml météo est terminé'; } catch (Exception $e) { die('Erreur : ' . $e->getMessage()); } ?> exemple3: <?php try { $bdd = new PDO('mysql:host=localhost; dbname=bd; charset=utf8', 'root', ''); $url='http://api.tameteo.com/index.php?api_lang=fr&localidad=8963&affiliate_id=wf7toya165cq&v=2&h=1'; $xml =simplexml_load_file($url); //declartion des variables /*$maxid=0; $tableau=array(13); $a=0; // selectionne tout ce qui est enfante de Balise foreach($xml->children() as $day) // selectionne tout ce qui est enfante de Balise { $incrementation_ID=$maxid++; $a=0; foreach($day->children() as $child) { //foreach($day->children() as $child) // { // Crée un tableau pour ranger les enfants de Balise ensemble $tableau[$a]=$child; $a++; // } } //implémente le tableau dans la base de données $rep2 = $bdd->prepare('INSERT INTO jour1(nomj1,symbolej1,tempminj1,tempmaxj1,windj1,windgustsj1,rainj1,humidityj1,pressurej1,snowlinej1,sun,moonj1, localinfoj1,hourj1) VALUES("", :symbol, :tempmin, :tempmax, :wind, :wind-gusts, :rain, :humidity, :pressure, :snowline, :sun, :moon, :local_info, :hour)'); $rep2->execute(array( 'symbol' => $tableau[0], 'tempmin' => $tableau[1], 'tempmax' => $tableau[2], 'wind' => $tableau[3], 'wind-gusts' => $tableau[4], 'rain' => $tableau[5], 'humidity' => $tableau[6], 'pressure' => $tableau[7], 'snowline' => $tableau[8], 'sun' => $tableau[9], 'moon' => $tableau[10], 'local_info' => $tableau[11], 'hour' => $tableau[12], )); } catch (Exception $e) { die('Erreur : ' . $e->getMessage()); } ?> voici partie de l'exemple 4: <?php $url='http://api.tameteo.com/index.php?api_lang=fr&localidad=8963&affiliate_id=wf7toya165cq&v=2&h=1'; //$xml =simplexml_load_file($url); //echo "<pre>".print_r($xml,1)."</pre>"; /*$doc_AL = new DomDocument(); $doc_AL->load('http://api.tameteo.com/index.php?api_lang=fr&localidad=8963&affiliate_id=wf7toya165cq&v=2&h=1'); //fichier en local pour les tests mais au final se sera une URL externe $res= $doc_AL->getElementsByTagName("day"); foreach($res as $day){ echo($day->getAttribute("name"))."<br />"; } ?> voici la structure de la base de données: nom base de donnees:bd nom table1: jour1 jour1(nomj1,symbolej1,tempminj1,tempmaxj1,windj1,windgustsj1,rainj1,humidityj1,pressurej1,snowlinej1,sunj1,moonj1, localinfoj1,hourj1) nom table2:jour jour(nom,symbole,tempmin,tempmax,wind,wind-gusts,rain,humidite,pressure,snowline,sun,moon,localinfo,hour) Je cherche une solution parfaite pour insérer tous les données dans fichier XML(remplir tous les tables) de l’URL : http://api.tameteo.com/index.php?api_lang=fr&localidad=8963&affiliate_id=wf7toya165cq&v=2&h=1 Nom des tables:jour,tempmin,tempmax,rain,humidité,rain,rain_gusts,sun,snowline,pressure,moon.............. vous pouvez vous donner un exemple pour lire le ficher et insérer tous les données dans ma base de données. Merci d'avance.