Reputation: 831
I'm trying to create an iframe which loads a random page from another site. The URL is simply the domain, followed by a number. So far, I have tried PHP:
$number = int rand(0,450000);
$page = 'http://www.example.com/'$number;
Problem is, I don't know how to create the iframe, so that $page goes into the <iframe src=""></iframe>
Perhaps something with javascript? I'm unfamiliar with JS, though. All I know is this from google:
var randomnumber=Math.floor(Math.random()*450001)
But again, I have no idea how to proceed.
Upvotes: 0
Views: 503
Reputation: 101614
<?php
$rand = rand(0,450000);
$page = 'http://example.com/' . $rand;
?>
<!-- ... -->
<iframe src="<?php echo $page; ?>"></iframe>
<!-- ... -->
Or, more concisely:
<iframe src="http://example.com/<?= rand(0, 450000); ?>"></iframe>
<?= ... ?>
is synonymous with <?php echo ... ?>
, btw.
Upvotes: 1