-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventajaxrequest.php
31 lines (26 loc) · 1.31 KB
/
eventajaxrequest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
//--------------------------------------------------------------------------
// Example php script for fetching data from mysql database
//--------------------------------------------------------------------------
$host = "databaseinstance.cmpvv7vrynza.us-west-2.rds.amazonaws.com";
$user = "arregoitiaJ1";
$pass = "Iamiamiam123";
$databaseName = "earthlinks";
$tableName = "Events";
//--------------------------------------------------------------------------
// 1) Connect to mysql database
//--------------------------------------------------------------------------
include 'DB.php';
$con = mysql_connect($host,$user,$pass);
$dbs = mysql_select_db($databaseName, $con);
//--------------------------------------------------------------------------
// 2) Query database for data
//--------------------------------------------------------------------------
$zipcode = mysql_escape_string($_GET['ZipCode']);
$result = mysql_query("SELECT * FROM $tableName WHERE ZipCode = $zipcode"); //query
$array = mysql_fetch_row($result); //fetch result
//--------------------------------------------------------------------------
// 3) echo result as json
//--------------------------------------------------------------------------
echo json_encode($array);
?>