Jump to content

Recommended Posts

Hi there, I got the info to use php random,

but I can't get it to load a random frame.

 

<?php
//Chooses a random number
$num = Rand (1,2);
//Based on the random number, gives a quote
switch ($num)
{
case 1:
<frameset rows="100%,*" border="0">
  <frame src="http://www.example.com" frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>;
break;
case 2:
<frameset rows="100%,*" border="0">
  <frame src="http://www.test.com" frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>;
break;

}
?>

Link to comment
https://forums.phpfreaks.com/topic/53609-loading-a-random-page-in-a-frame/
Share on other sites

<?php
//Chooses a random number
$num = Rand (1,2);
//Based on the random number, gives a quote
switch ($num)
{
case 1:
?><frameset rows="100%,*" border="0">
  <frame src="http://www.example.com" frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>
<?php
break;
case 2:
?>
<frameset rows="100%,*" border="0">
  <frame src="http://www.test.com" frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>
<?php
break;
}
?>

<?php
//Chooses a random number
$num = Rand (1,2);
//Based on the random number, gives a quote
switch ($num)
{
case 1:
?><frameset rows="100%,*" border="0">
  <frame src="http://www.example.com" frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>
<?php
break;
case 2:
?>
<frameset rows="100%,*" border="0">
  <frame src="http://www.test.com" frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>
<?php
break;
}
?>

that works ;) , btw is this code fast to handle for the server or could it be way faster with some other code ?

 

<?php
$num = rand(1,2);
echo "<frameset rows=\"100%,*\" border=\"0\">\n  <frame src=\"";
switch ($num) {
case 1: echo "http://www.example.com";
break;
case 2: echo "http://www.test.com";
break;
}
echo "\" frameborder=\"0\" />\n  <frame frameborder=\"0\" noresize />\n</frameset>";
?>

 

That may be quicker.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.