Advertisement
colmulhall

Untitled

Apr 1st, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 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.         // run the query
  31.         mysqli_query($con, $sql);
  32.     }
  33.     else
  34.         print "Database NOT Found ";
  35.  
  36.     mysqli_close($con);
  37.     }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement