SA-MP Forums Archive
http with php - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: http with php (/showthread.php?tid=632720)



http with php - Bussyman - 18.04.2017

Hi,

I i'am using http to call to php file, there i want to load something, like 10 last killer names, and send again to my callback. I don't know how to make answer, i know need use echo, but if there 10 names, how to echo that? and how in callback get it values.


Re: http with php - OsteeN - 18.04.2017

You could use JSON.


Re: http with php - Zav1337 - 18.04.2017

Like OsteeN said, you could use JSON. I made small script for you. This is how your php file could look like if you use JSON.

PHP код:
<table width="500">
    <tr>
        <td> Killer </td>
        <td> Weapon </td>
        <td> Player </td>
    </tr>
<?php
    $i 
0;
    
$json json_decode(file_get_contents("JSON URL"));
    foreach(
$json->kills as $data)
    {
        if (
$i++ == 10) break;
        echo 
"<tr>";
            echo 
"<td>".$data->killer."</td>";
            echo 
"<td>".$data->weapon."</td>";
            echo 
"<td>".$data->player."</td>";
        echo 
"</tr>";
    }
?>
</table>