-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
36 lines (28 loc) · 848 Bytes
/
test.php
File metadata and controls
36 lines (28 loc) · 848 Bytes
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
32
33
34
35
36
<?php
if (!$link = mysql_connect('localhost', 'root', 'sid')) {
echo 'Could not connect to mysql';
exit;
}
if (!mysql_select_db('sid', $link)) {
echo 'Could not select database';
exit;
}
$arrReturn=array_merge($_GET,$_POST);
$partQry="";
if(isset($arrReturn['fname']))$partQry.=" and first_name like '%".$arrReturn['fname']."%' ";
if(isset($arrReturn['lname']))$partQry.=" and last_name like '%".$arrReturn['lname']."%' ";
$sql = "SELECT * FROM names where 1 $partQry limit 5";
//$sql = 'show create table names';
$result = mysql_query($sql, $link);
if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_assoc($result)) {
$arrname[]=($row);
//echo $row['foo'];
}
echo json_encode($arrname);
mysql_free_result($result);
?>