Ejemplos json

Page 1

qwertyuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopasdfgh jklzxcvbnmqwertyuiopasdfghjklzxcvb Ejemplos Json nmqwertyuiopasdfghjklzxcvbnmqwer tyuiopasdfghjklzxcvbnmqwertyuiopas POR: Erwin Guillermo Juárez Carrasco Samanta Pérez Miranda dfghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwertyuio pasdfghjklzxcvbnmqwertyuiopasdfghj klzxcvbnmqwertyuiopasdfghjklzxcvbn mqwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasdf ghjklzxcvbnmqwertyuiopasdfghjklzxc vbnmqwertyuiopasdfghjklzxcvbnmrty uiopasdfghjklzxcvbnmqwertyuiopasdf ghjklzxcvbnmqwertyuiopasdfghjklzxc


C贸digo Json 1 <?php $link = mysqli_connect("localhost", "root", "", "json") or die("Error " . mysqli_error($link)); //consultation: $query = "SELECT * FROM frutas" or die("Error in the consult.." . mysqli_error($link)); //echo $query; //execute the query. //$result = $link->query($query); $result =$link->query($query) or die("Error in the consult.." . mysqli_error($link)); //display information: while($row = mysqli_fetch_array($result)) { echo $row[0]." "; echo $row[1]." " ; echo $row[2]." "."<br>"; } ?>


C贸digo Json 2 <?php $json = '[{"0":"1","id_fruta":"1","1":"Manzana","nombre_fruta":"Manzana","2":"100","cantidad":"100"}, {"0":"2","id_fruta":"2","1":"Platano","nombre_fruta":"Platano","2":"167","cantidad":"167"}, {"0":"3","id_fruta":"3","1":"Pera","nombre_fruta":"Pera","2":"820","cantidad":"820"}]'; $array = json_decode($json); print_r($array); echo $array[0]->nombre_fruta; foreach($array as $obj){ $id_fruta = $obj->id_fruta; $nombre_fruta = $obj->nombre_fruta; $cantidad = $obj->cantidad; echo $id_fruta." ".$nombre_fruta." ".$cantidad; echo ""; } ?>


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.