PDA

View Full Version : php modification for a page


HipHopFranco
08-26-2004, 12:27 AM
I got this part of php code I wanna incorporate in a .php file...it selects a random image:

<?php

global $value;

srand((double)microtime()*1000000);
$value = rand(0,1);

if($value==0){
$img="http://hiphopfranco.rapidenet.ca/sponsors/sponsor1.gif";
}
if($value==1){
$img="http://hiphopfranco.rapidenet.ca/sponsors/sponsor2.gif";
}

?>

and, lower

<a href="blop.html" target="_blank"><img src=<? echo($img); ?> width="468" height="60" border="0"></a>

I'm just trying to figure out where I should put this because the whole thing is ran by templates...

Sylvus
08-26-2004, 03:13 PM
I'd put it in global.php

Xenon
08-26-2004, 03:21 PM
phpinclude_start (template) would be better

Sylvus
08-26-2004, 03:24 PM
Hi Xenon! I just looked under my vB2 and I do not have a phpinclude_start template. Is this something that needs to be added manually or perhaps it was accidently removed? I hope by not having this phpinclude_start template in my vB2 forum does not cause any serious problems or issues with the database!

Xenon
08-26-2004, 03:31 PM
in vb2 it's called just phpinclude :)

HipHopFranco
08-26-2004, 05:45 PM
I tried to put the top part in the "phpinclude" template:

global $value;

srand((double)microtime()*1000000);
$value = rand(0,1);

if($value==0){
$img="http://hiphopfranco.rapidenet.ca/sponsors/sponsor1.gif";
}
if($value==1){
$img="http://hiphopfranco.rapidenet.ca/sponsors/sponsor2.gif";
}


And I tried to put the other part in the "forumdisplay" template (I wanna put the image in the "forumdisplay template"):

<a href="blop.html" target="_blank"><img src=<? echo($img); ?> width="468" height="60" border="0"></a>


But it doesn't work. Sombody knows the problem? :(

Xenon
08-27-2004, 01:59 PM
change
<a href="blop.html" target="_blank"><img src=<? echo($img); ?> width="468" height="60" border="0"></a>

into
<a href="blop.html" target="_blank"><img src="$img" /> width="468" height="60" border="0"></a>

that should work

HipHopFranco
08-27-2004, 08:23 PM
Thank you Xenon! You're the man!!!

It works perfectly fine now.

Xenon
08-28-2004, 03:32 PM
you're welcome :)