Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header("Content-type:application/json");
- $servername = "sasdasdasdadsdom";
- $username = "adsdas78";
- $password = "veasdasd1305";
- $database = "fasdfasdfasdf";
- //creating a new connection object using mysqli
- $conn = new mysqli($servername, $username, $password, $database);
- //if there is some error connecting to the database
- //with die we will stop the further execution by displaying a message causing the error
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- //if everything is fine
- //creating an array for storing the data
- $heroes = array();
- //this is our sql query
- $sql = "SELECT * FROM `mov_en` LIMIT 0 , 30;";
- //creating an statment with the query
- $stmt = $conn->prepare($sql);
- //executing that statment
- $stmt->execute();
- //binding results for that statment
- $stmt->bind_result($id, $name,$img,$quality,$down);
- //looping through all the records
- while($stmt->fetch()){
- //pushing fetched data in an array
- $temp = [
- 'id'=>$id,
- 'name'=>$name,
- 'img'=>$img,
- 'quality'=>$quality,
- 'down'=>$down
- ];
- array_push($heroes, $temp);
- }
- echo json_encode($heroes);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement