0

I want to insert ads, and they must change randomly (shuffle). I dont know ftp account for the site, I can only add just from my admin panel as an ads code.

I created these pages named r1.php:

$numbers = range(1, 3);
shuffle($numbers);
foreach ($numbers as $number) {
    $rand .= $number.",";
    mysqli_query("UPDATE random SET reklam='$rand' where id=1 ");
}
$sql = mysqli_query("SELECT reklam FROM random where id=1 limit 0,1 ");
$dongu = mysqli_fetch_row($sql);
$parca = explode(",",$dongu['0']);?>
<img src="r<?php echo $parca[0]; ?>.png"  />

And this page named r2.php:

$numbers = range(1, 3);
shuffle($numbers);
foreach ($numbers as $number) {
    $rand.=$number.",";
    mysqli_query("UPDATE random SET reklam='$rand' where id=1 ");
}
$sql = mysqli_query("SELECT reklam FROM random where id=1 limit 0,1 ");
$dongu = mysqli_fetch_row($sql);
$parca = explode(",",$dongu['0']);?>
<img src = "r<?php echo $parca[1]; ?>.png"  />

and I added an iframe:

<iframe src="http:/www.mysite.com/r1.php" >

as well as:

<iframe src="http:/www.mysite.com/r2.php" >

It doesn't work because the same ads are showing, but I want to avoid the same ads on one page.

But there is 2 ads sub-bottom. Not one place there is 2 ads in one page with 2 places.

Is it possible to get these adds to shuffle with javascript (or other)?

Rasclatt
  • 12,498
  • 3
  • 25
  • 33
Bagova
  • 161
  • 16
  • 3
    Please, [don't use `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) in new code. They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://us1.php.net/pdo) or [MySQLi](http://us1.php.net/mysqli). – Jay Blanchard Dec 29 '14 at 22:40
  • Thanks a lot, you are right, i'll pass in a short time.. – Bagova Dec 29 '14 at 22:54
  • The (redundant) code does not make any sense. Your are updating that record 3 times in the foreach with data that is not even related. Please specify how the adds are stored on your server first – DarkBee Dec 29 '14 at 22:55
  • In mysql i upadate them 1,2,3,4,5 (shuffled) (4,3,5,2,1) or etc.. And i use r1.png, r2.png, r3.png – Bagova Dec 29 '14 at 23:01
  • How do u add the iframes then to the website? – DarkBee Dec 29 '14 at 23:30

0 Answers0