Created
December 16, 2013 04:13
-
-
Save siteslave/7982179 to your computer and use it in GitHub Desktop.
[ประกอบหนังสือ Bootstrap]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dsn = 'mysql:host=localhost; dbname=test'; | |
| $username = 'root'; | |
| $password = ''; | |
| try { | |
| $conn = new PDO( $dsn, $username, $password); | |
| $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); | |
| } catch ( PDOException $e ) { | |
| echo 'Connection failed: ' . $e->getMessage(); | |
| } | |
| $callback = $_GET['callback']; | |
| $sql_total = 'select count(*) as total from hospitals'; | |
| $st = $conn->prepare($sql_total); | |
| $st->execute(); | |
| $rows_total = $st->fetch(); | |
| $json = '{"ok": 1, "total": ' . $rows_total['total'] . '}'; | |
| echo $callback . '(' . $json . ')'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment