-
Notifications
You must be signed in to change notification settings - Fork 1
/
Search.php
43 lines (40 loc) · 1.05 KB
/
Search.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
32
33
34
35
36
37
38
39
40
41
42
43
<?php
function get_content($URL){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>
<html>
<head>
<title> search </title>
</head>
<body>
<form action="" >
<input type="text" name="search"/>
<button type="submit"> search</button>
<br>
<?php
if(!empty($_GET['search'])){
$URL='http://pubapi.yp.com/search-api/search/devapi/search?searchloc=91203&term='.urlencode($_GET['search']).'&format=json&key=0z02n4301r';
$JSON= get_content($URL);
$array=json_decode($JSON,true);
foreach($array['searchResult']['searchListings']['searchListing'] as $i)
{
$id=$i['listingId'];
$name=$i['businessName'];
echo "<a href='viewDetails.php?id=$id'>$name</a>";
echo "<br><br>";
}
}
?>
</form>
<form action="Coupons.php">
<button type="submit"> Copoun </button>
</form>
</body>
</html>