# Help with randomly generating page

**URL:** <https://forum.kirupa.com/t/help-with-randomly-generating-page/100665>\
**Category:** Uncategorized\
**Created:** [February 1, 2004, 4:10am UTC](https://forum.kirupa.com/t/help-with-randomly-generating-page/100665 "2004-02-01T04:10:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yeldarb](https://avatars.discourse-cdn.com/v4/letter/y/51bf81/32.png) [@Yeldarb](https://forum.kirupa.com/u/Yeldarb)\
**Post date:** [February 1, 2004, 4:10am UTC](https://forum.kirupa.com/t/help-with-randomly-generating-page/100665/1 "2004-02-01T04:10:01Z")

</div>

I am trying to set a variable to a random value, 1 or 2 (as of now, but may be more options later). And depending on the random value of the variable, I want different content to appear. I can’t figure out what’s wrong with my code… It always produces the first option…

```php

<?PHP

$pageNumber = rand(1,2);
$pageNumber = (string)$pageNumber;

if ("$pageNumber" == "1") {
	echo '
	<body bgcolor="#333333">

	<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  		<tr>
    		<td align="center" valign="middle">
					<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="556" height="363">
      				<param name="movie" value="temporary.swf">
      				<param name="quality" value="high">
      				<embed src="temporary.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="556" height="363"></embed>
    			</object>
			</td>
  		</tr>
	</table>
	';
} elseif ("$pageNumber" == "2") {
	echo '
	<body bgcolor="#FFFFFF">

	<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  		<tr>
    		<td align="center" valign="middle">
				<img src="images/beer.jpg">
			</td>
  		</tr>
	</table>
	';
}

?>

```
