Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $conn = mysqli_connect("[host]","[username]","[password]","[database]") or die ("Error".mysqli_error($conn));
- header('content-type: application/json');
- $sql = "select * from [table_name]";
- $result = mysqli_query($conn, $sql) or die ("Error".mysqli_error($conn));
- $myArray = array();
- while ($row = mysqli_fetch_assoc($result)) {
- $myArray[] = $row;
- }
- mysqli_close($conn);
- $json = json_encode($myArray);
- echo $json;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement