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();
- //Check if database is found
- $db_found = mysqli_select_db($con, $database)or die("cannot select DB");
- if ($db_found)
- {
- //Insert into the database
- mysqli_select_db($con, $database)or die("cannot select DB");
- $sql = "INSERT INTO event_list (title, description, location)
- VALUES
- ('title', 'desc', 'phoenix park')";
- // run the query
- mysqli_query($con, $sql);
- }
- else
- print "Database NOT Found ";
- mysqli_close($con);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement