0
$(document).on('click','#Show1',function(e)
        {
        country = e.target.id
        adress = "2.php?country=" + country
        $.get(adress, Get2)
        })      
    function Get2(answer)
        {
        //alert(answer["p"])
        $("#Show2").html(answer)
        }

PHP

<?php
require 'vendor/autoload.php';
$country = $_GET["country"];
$adress="http://localhost:3000/City?CountryId=$country";
$clienthttp=new EasyRdf\Http\Client($adress);
$req=$clienthttp->request();
$resultJSON=$req->getBody();
$city=json_decode($resultJSON);

    echo "<div style='text-align: center; margin-bottom: 5vh; font-size: 3vh;'>"; 
    echo "<span> Name </span>";
    echo "<span style='margin-left: 10vw'> Surface </span>";
    echo "<span style='margin-left: 10vw'> Population </span>";
    echo "</div>";
foreach ($city as $cities)
{
    echo "<div style='text-align: center; margin-bottom: 20vh;'>"; 
    echo "<span style='font-size: 3vh;'> $cities->name </span>";
    echo "<input type='button' id='$cities->id' style='height:5vh; width: 5vw;' value='Delete'>";
    echo "<span style='margin-left: 10vw'> $cities->surface </span>";
    echo "<span style='margin-left: 10vw'> $cities->population </span>";
    echo "</div>";
}
    echo "<p style='display:none'> $country </p>"
?>

I'm trying to only access the last paragraph of the server's response (more specifically, I'm looking to send the country for which the cities were retrieved back to the frontend to store in a variable, I'll need that later. However, I have no clue how to do that. The commented line is the one that should be changed somehow. Thanks in advance

0 Answers0