Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = 'root';
- $password = '';
- $database = 'test';
- $host = 'localhost';
- // create connection to the database
- $con = mysqli_connect($host, $username, $password, $database);
- // select database
- mysqli_select_db($con, $database)or die("cannot select DB");
- // return all event titles from the database ordered by date
- $sql = "select id, title, location, date from event_list order by id desc";
- $result = mysqli_query($con, $sql);
- $json = array();
- // get each row of data from the database
- if(mysqli_num_rows($result))
- {
- while($row = mysqli_fetch_assoc($result))
- {
- $json['event_list'][] = $row;
- }
- echo json_encode($json);
- }
- mysqli_close($con);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement