Jump to content

[SOLVED] Case PHP


ItsWesYo

Recommended Posts

I'm trying to use a "random number" php code that I know works. Here is the whole page code:

 

index.php

<?php
include ("includes/header.php");

$page = ((isset($_REQUEST['id']))?($_REQUEST['id'])''));

switch($page)
{

case "4": {
echo("

<?php
srand ((double) microtime( )*1000000);
$random = rand(0,10);
echo "$random";
?>

");
break;}


default: {
echo("

blah blah blah

");
break;}

}

include ("includes/footer.php");
?>

 

 

I just want that piece to show up, but it wont work. It takes out the $ variable.

Link to comment
https://forums.phpfreaks.com/topic/45835-solved-case-php/
Share on other sites

Do you want the random number to echo or the whole string? Since you're already in PHP you don't need the second "<?php" or "?>".

 

Try this:

<?php
include ("includes/header.php");

$page = ((isset($_REQUEST['id']))?($_REQUEST['id'])''));

switch($page)
{
     case "4":
        $random = rand(0,10);
        echo $random;
        break;


    default:
        echo("blah blah blah");
        break;
}

include ("includes/footer.php");
?>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/45835-solved-case-php/#findComment-222702
Share on other sites

All HTML is in the header.php file. The PHP works when I include it from another file. But, I don't want a lot of files cause that page (index.php) is an "extra" page, like random quotes, numbers, etc.

 

header.php

<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>

<table width='800' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr>
<td colspan='6'>
<img src='http://wes.thexwl.com/img/01.jpg' width='800' height='14'>
</td>
</tr>
<tr>
<td rowspan='6' background='http://wes.thexwl.com/img/02.jpg'>
 
</td>
<td colspan='3' background='http://wes.thexwl.com/img/03.jpg'>
<table width='100%' border='0' align='center' cellpadding='2' cellspacing='0'>
<tr>
<td width="12%"> </td>
<td width="88%"> </td>
</tr>
<tr>
<td> </td>
<td><span class="style1">i8 Wes</span></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</td>
<td>
<img src='http://wes.thexwl.com/img/04.jpg' width='20' height='117' border='0'></a>
</td>
<td rowspan='6' background='http://wes.thexwl.com/img/05.jpg'>
 
</td>
</tr>
<tr>
<td height='37' colspan='4' background='http://wes.thexwl.com/img/06.jpg'>
<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr>
<td width='100%'>
What should go here?
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height='22' colspan='4' background='http://wes.thexwl.com/img/07.jpg'>
 
</td>
</tr>
<tr>
<td background='http://wes.thexwl.com/img/08.jpg' class='content'>

<b>Navigation:</b><br>
<a href='http://wes.thexwl.com/1/index.php'>Home</a><br>
<a href='http://wes.thexwl.com/1/about.php'>About</a><br>
<a href='http://wes.thexwl.com/1/contact.php'>Contact</a><br>
<a href='http://wes.thexwl.com/1/games.php'>Games</a><br>
<a href='http://wes.thexwl.com/1/links.php'>Links</a><br>
<a href='http://wes.thexwl.com/1/other.php'>Other</a><br>
<a href='http://wes.thexwl.com/1/gallery.php'>Photo Gallery</a><br>
<a href='http://wes.thexwl.com/1/videos.php'>Videos</a><br><br>

<b>Affiliates:</b><br>
<a href='http://wes.thexwl.com/index.php'>i8 Network</a><br>
<a href='http://wes.thexwl.com/2/index.php'>i8 Polairia</a><br>
<a href='http://wes.thexwl.com/3/index.php'>i8 Scripts</a><br>

</td>
<td background='http://wes.thexwl.com/img/09.jpg'>
 
</td>
<td height='465' colspan=2 background='http://wes.thexwl.com/img/10.jpg' class='content'>
<table width='100%'  border='0' cellspacing='0' cellpadding='4'>
<tr>
<td>
<div style='width: 560; height: 440; overflow: auto;'>

Link to comment
https://forums.phpfreaks.com/topic/45835-solved-case-php/#findComment-222719
Share on other sites

I made a copy of your code on my machine:

<?php
include ("includes/header.php");

$page = ((isset($_REQUEST['id']))?($_REQUEST['id'])''));

switch($page)
{
     case "4":
        $random = rand(0,10);
        echo $random;
        break;


    default:
        echo "blah blah blah";
        break;
}

//include ("includes/footer.php");
?>

 

It works fine, no weird output.

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/45835-solved-case-php/#findComment-222726
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.