Advertisement
colmulhall

Untitled

Apr 1st, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2.     $username = 'root';
  3.     $password = '';
  4.     $database = 'test';
  5.     $host = 'localhost';
  6.  
  7.     // create connection to the database
  8.         $con = mysqli_connect($host, $username, $password, $database);
  9.  
  10.     // select database
  11.     mysqli_select_db($con, $database)or die("cannot select DB");
  12.  
  13.     // return all event titles from the database ordered by date
  14.     $sql = "select id, title, location, date from event_list order by id desc";
  15.  
  16.         $result = mysqli_query($con, $sql);
  17.     $json = array();
  18.  
  19.     //Check if database is found
  20.     $db_found = mysqli_select_db($con, $database)or die("cannot select DB");
  21.     if ($db_found)
  22.     {
  23.         //Insert into the database
  24.         mysqli_select_db($con, $database)or die("cannot select DB");
  25.        
  26.         $sql = "INSERT INTO event_list (title, description, location)
  27.             VALUES
  28.             ('title', 'desc', 'phoenix park')";
  29.  
  30.         mysqli_query($con, $sql);
  31.  
  32.         print "Inserted";
  33.     }
  34.     else
  35.         print "Database NOT Found ";
  36.  
  37.     mysqli_close($con);
  38.     }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement