JQuery
i’m fetching data from a table through AJAX and want to convert an element into php variable like-id(so that i can determine whose data is this).
```html
PHP
here is my php code which sending me data after fetch
if (isset( $_POST['sellerid']))
{
// code...
$get = search_ajax($_POST['sellerid']) ;
echo $get ;
}
function search_ajax($seller_id){
global $con ;
$output = '';
$query = "SELECT * FROM dist_register WHERE ( name LIKE '%".$_POST["query"]."%' OR farm_name LIKE '%".$_POST["query"]."%' OR address LIKE '%".$_POST["query"]."%' OR mob_no LIKE '%".$_POST["query"]."%') AND seller_id = '$seller_id'";
$result = mysqli_query($con, $query);
$output = '<ul class="list-unstyled">';
if (mysqli_num_rows($result) > 0)
{
// code...
while ($row = mysqli_fetch_array($result))
{
// code...
$output .='<divv> <li id="add_s">'.$row["farm_name"].", ".$row["address"].'</li>';
$output .='<sup class="ml-4 bg-white mt-0 pt-0" style="font-size:13px;"> Country -: '.$row["country"]. ", Mob.No -: ".$row["mob_no"];
$output .='</sup></divv>';
// $output .='<li>'.$row["property_add"].'</li>';
// $output .='<li>'.$row["property_name"].'</li>';
$output .= '<spann class="text-primary sr-only" id="ss">'.$row["dist_id"].'</spann>';
}
}
else
{
$output .='<divv><li>No data available</li></divv>';
// $output .='';
}
$output .= '</ul>';
// echo $output;
return $output;
}