i am new to php webservice and JSON. Now i am trying to get the keyword from url and search whether is it in Database. keywords can be one or more. deliver the result in jSON format. the result will be some url that connected with the value. url will be in database.
<?php
include_once('confi.php');
error_reporting(E_ALL);
//Get the variables here
$key_word = isset($_GET['key_word']) ? mysqli_real_escape_string($conn, $_GET['key_word']) : "";
$result = explode(',', $key_word);
print_r($result);
$sql = 'SELECT * FROM `kw` WHERE key_word="'.$key_word.'"';
$Obj='';
$query = mysqli_query($conn,$sql) or trigger_error(mysqli_error()." ".$sql);
while($row = mysqli_fetch_array($query))
{
$key_word = $row['key_word'];
$Url = $row['Url'];
}
}
/* Output header */
header('Content-type: application/json');
$Obj->key_word = "$key_word";
$Obj->Url = "$Url";
$JSON = json_encode($Obj);
echo $JSON;
?>
i am getting null value for this code. please help me to do it.
i am getting the result like this. it sholud me display separaly and those two will have separate urls.