I have something that looks like this:
Code: Select all
<! here is a random number generator>
<?php
for ($i = 0, $z = strlen($a = '0123456789')-1, $s = $a{rand(0,$z)}, $i =
1; $i != 1; $x = rand(0,$z), $s .= $a{$x}, $s = ($s{$i} == $s{$i-1} ?
substr($s,0,-1) : $s), $i=strlen($s));
?>
<?php
function rand_chars($c, $l, $u = FALSE) {
if (!$u) for ($s = '', $i = 0, $z = strlen($c)-1; $i < $l; $x =
rand(0,$z), $s .= $c{$x}, $i++);
else for ($i = 0, $z = strlen($c)-1, $s = $c{rand(0,$z)}, $i = 1; $i !=
$l; $x = rand(0,$z), $s .= $c{$x}, $s = ($s{$i} == $s{$i-1} ?
substr($s,0,-1) : $s), $i=strlen($s));
return $s;
}
?>
<!this generates the first ad URLs and filenames based on $catid and random number >
<p align="right">
<a href="/buttons/<? echo $catid; ?>/ad<? echo $s; ?>.htm">
<img src="/buttons/<? echo $catid; ?>/ad<? echo $s; ?>.gif" alt="" border="0"></a>
<!this generates the second ad URLs and filenames based on $catid and random number with a 1 subtracted >
<p align="right">
<a href="/buttons/<? echo $catid; ?>/ad<? echo $s -1; ?>.htm">
<img src="/buttons/<? echo $catid; ?>/ad<? echo $s -1; ?>.gif" alt="" border="0"></a>
<br>
I want to be able to do a couple of things that I am not having success with
1) Need to be able to call to an adX.txt file that would have its location constructed in php in the same way that the image and link url are constructed above . I think I need only echo this file contents as it would simply be raw html code
2) I need to be able to tell the script that if the value of "$s" is "0" that "0" -1 is 9. What the script returns now for the urls shows a -1 in the filename.
3) I would like to be able to fill the 'alt' tag as well using yet another file, or perhaps the same text file in 1
I think I am messing up somewhere on syntaxes especially where I am escaping to HTML and back to PHP , but I can not be sure. IO have tried several solutions and can not seem to get any to work
Any help appreciated
thanks