I can’t do the limitation

Asked

Viewed 65 times

0

Hello I have the following problem:
When I press the button it generates 24 more images, this is not my wish, I want you to continue only 24 and just change for the following. (see here)

code:

    <head>
<title>Hebbo Gadget</title>
</head>
<style>
.hebbo {height: auto;overflow:hidden;width:230px;}
.emblema {float: left;height:50px;width:50px;margin: 3px;border-radius: 15px;background-repeat: no-repeat;background-position: center center;}
</style>

<div class="hebbo" id='test'>

<?php
$url    = "http://hebbohotel.com.br/swf/gamedata/hebbo_texts.txt?9761831";
$data   = file_get_contents($url);

$newlines   = array("\n" ,"\r", "\r\n", ">", "<", "/");
$content    = str_replace($newlines, "", html_entity_decode($data));

$statusHtml = '/badge_desc_(.+?)=/';
preg_match_all($statusHtml, $content, $statusRaw);

$badges     = implode("-", $statusRaw[0]);
$badgeVar   = explode("=-badge_desc_", $badges);
$badgeVar2  = str_replace("=", "", $badgeVar);
$badgeVar3  = str_replace("badge_desc_", "", $badgeVar2);
$number     = count($badgeVar3);

$i = 1;
$e = 24;
// aqui você entra com incremento de variável
$maisClique = ((isset($_GET['cliquei']) and !empty($_GET['cliquei']))?$_GET['cliquei']:false);

if(isset($maisClique) and !empty($maisClique)){
    $e += $maisClique;
}
while ($i <= $e)
{
    $number     = $number - 1;
    $imageUrl   = "http://hebbohotel.com.br/swf/c_images/album1584/" . $badgeVar3[$number] . ".gif";
    echo '<div class="emblema" style="background:url(' . $imageUrl . ') no-repeat center,  #E7E7E7;"></div>'; // changed this echo to display the image.
    $i++;
}
// aqui você define o valor $cliques que será calculado em $number para alterações da matriz
if(isset($_GET['cliquei']) and !empty($_GET['cliquei'])){
    $cliques = $_GET['cliquei'] + 24;
}else{
    $cliques = 24;
}
?>
<input type="button" onclick="window.location.replace('http://<?php echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?cliquei=".$cliques ?>')" value="cliquei" />
</div>

1 answer

1

I think the mistake might be in this part my friend.

"if(isset($_GET['cliquei']) and !empty($_GET['cliquei'])){
    $cliques = $_GET['cliquei'] + 24;
}else{
    $cliques = 24;
}"

For you icrementando more 24 generates inclusion, and you need to overwrite the 24 again and not increase more 24.

  • Should make the value $i go back to 1 and replace the existing ones by restarting the iteration again.

  • I’ve changed a few things that I understand is what you asked for. Check there and you can check my url: http://www.atualgeek.com/test In the link is the code made.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.