Currently I do a search using my code I only get the first page, to change the results I have to do this manually, how can I change the $ page variable with the click of a button.
My code:
<?php
function buscaUser($user)
{
$opts = [
'http' => [
'method' => 'GET',
'header' => [
'User-Agent: PHP'
]
]
];
$page = 1;
$user= $_GET['username'];
$context = stream_context_create($opts);
$content = file_get_contents('https://api.github.com/search/users?q='.$user."&page=".$page, false, $context);
$json = json_decode($content,true);
$jsoncount = count($json['items']);
$totalcount = $json['total_count'];
$page = $totalcount/30;
echo "<h1> Total de :".$totalcount." Usuarios encontrados.</h1> <br>";
for ($numItem = 0 ; $numItem <= $jsoncount-1; $numItem++){
echo "<div class='usuario'>";
echo "<a href=".$json['items'][$numItem]['html_url']."><img class='img-thumbnail' width='100px' height='100px' src=".$json['items'][$numItem]['avatar_url']."/><br>";
echo $json['items'][$numItem]['login']."</a><br>";
echo "Pontos: ".$json['items'][$numItem]['score']."<br>";
echo "</div>";
}
}
?>