Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 16th, 2012  |  syntax: None  |  size: 0.54 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. $name = $_POST['name'];
  3. $age = $_POST['age'];
  4.  
  5. $mysqlhost = "localhost";
  6. $mysqluser = "root";
  7. $mysqldb = "jquery";
  8. $mysqlpwd = "1234";
  9.  
  10.  
  11. $connection = mysql_connect($mysqlhost, $mysqluser, $mysqlpwd);
  12. mysql_select_db($mysqldb, $connection);
  13. mysql_query('INSERT INTO contact (Name, Age) VALUES ("' . $name . '", "' . $age . '")');
  14. $result = mysql_query("Select * from contact");
  15. $x = array();
  16. $i = 0;
  17. while($array = mysql_fetch_assoc($result)) {
  18.         $x[$i] = $array;
  19.         $i++;
  20. }
  21.  
  22.  
  23. $json = json_encode(array("d"=>$x));
  24. echo $json;
  25. ?>