Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host="localhost";
- $username="root";
- $password="";
- $db_name="park";
- // Create connection to the database
- $con = mysqli_connect("$host", "$username", "$password", "$database");
- // Select database
- mysql_select_db("$db_name")or die("cannot select DB");
- // Run an sql query to return data from the database
- $sql = "select title from events";
- $result = mysqli_query($con, $sql);
- $json = array();
- // Get each row of data from the database
- if(mysql_num_rows($result))
- {
- while($row = mysql_fetch_assoc($result))
- {
- $json['events'][] = $row;
- }
- echo json_encode($json);
- }
- mysql_close($con);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement