Pop-up Images

Asked

Viewed 89 times

1

Hello, I have a PHP here that "generates" images newly hosted in the game in which I play, and I was wondering if it is possible to make it generate more images, without repeating any, is it possible? (it is important to always continue the same value of images on the page, but just change the images)

 <?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;


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++;
}

?>

I want when you press a button, it fetches the next images, hosted php link: http://rafagarcia.pe.hu/hebbo.php

2 answers

0

Well, after seeing the page I figured out there’s still no button, so get on with it:

    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;
}
// aqui encerra o php e entra o botão cliquei
?>
<input type="button" onclick="window.location.replace('http://<?php echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?cliquei=".$cliques ?>')" value="cliquei" />

//--- fim

I believe this is the way for your upgrade matrix!

  • Hello, look what’s happening: http://rafagarcia.pe.hu/hebbo2.php

  • can help me?

0

On a quick look at your code, your question may have two answers:

1 - I noticed that it was limited to 24 iterations:

$i = 1;
$e = 24;

while ($i <= $e)

If you leave the $variable and interactivity dynamics per click:

$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...

2 - If you want to replace the 24 images with new images from your server, then the index of the array will be changed:

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

// aqui você altera a porção dos elementos do array: 24, 48, 72, 96...
$number     = ((isset($maisClique) and !empty($maisClique))?($number - $maisClique):$number);

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++;
}

But this template asks you to run the page at each click, if you want to do without page load you need to increment an ajax, or jquery.

Note: ( $number - 1 ) refers to the decrease of the matrix index, if at the course of 24 iterations the index zeroes, or empties, a null value will be returned for each image, the most common is to observe increment, ( $number + 1 ), in the matrix index!

Note 2: $number is the total of indices:

$number     = count($badgeVar3);

As it is, you ordered the code to bring the last 24 elements in reverse order!

  • I had not opened the page in question I just observed its code... Now sent the button with the previous checks in php for dynamic update, can be for the $variable and for the variable $number, you choose!

Browser other questions tagged

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