|
Posted by Jeff North on 12/09/07 02:18
On Sat, 08 Dec 2007 18:52:47 GMT, in alt.php "@Homeonthecouch"
<me@home.com>
<3KB6j.71057$EU1.17768@fe1.news.blueyonder.co.uk> wrote:
>| Got to be easier if I just post the whole lot so your not guessing,
>| Someone else has asked this question on the owners website but he says he will be busy with studies until November so I guess it over ran whatever it was he was studying.
>|
>|
>| Here's the whole lot then.
>|
>| I really appreciate your help and patience with this.
>| If there is a 'target' value added in, will it still validate in strict dtd mode?
>|
>|
>| <?php
>|
>| $option = "banner";
>|
>| $sites[0] = array("http://www.site1.com", "Text1", 5, "images/mybannerimage1.jpg");
>| $sites[1] = array("http://www.site2.com", "Text2", 1, "images/mybannerimage2.jpg");
>| $sites[2] = array("http://www.site3.com", "Text3", 5, "images/mybannerimage3.jpg");
>| $sites[3] = array("http://www.site1.com", "Text1", 1, "images/mybannerimage4.jpg");
Step 1. Add a flag to each item to tell the HTML section what to do.
So your $site array will look like (reduced info for line wrap):
$sites[0]=array("http://www.s1.com","Text1",5,"myb1.jpg",true);
$sites[1]=array("http://www.s2.com","Text2",1,"myb2.jpg",false);
$sites[2]=array("http://www.s3.com","Text3",5,"myb3.jpg",false);
$sites[3]=array("http://www.s1.com","Text1",1,"myb4.jpg",true);
>| $countsites = count($sites);
>|
>| for($i=0; $i<$countsites; $i++)
>| {
>| for($x=0; $x<$sites[$i][2]; $x++)
>| {
>| if($option != null)
>| {
>| $mylist[] = array($sites[$i][0],$sites[$i][1],$sites[$i][3]);
Step 2. Include the flag within the list
$mylist[]=array($sites[$i][0],$sites[$i][1],$sites[$i][3],$sites[$i][4]);
>| }
>| else
>| {
>| echo("Error deciding option.");
>| exit();
>| }
>| }
>| }
>|
>| $countlist = count($mylist);
>|
>| $countlist = $countlist - 1;
>|
>| $picker = rand(0, $countlist);
>|
>| if($option == "link")
>| {
>| echo("<a href='" . $mylist[$picker][0] . "'>" . $mylist[$picker][1] . "</a>");
>| }
>|
>| else if($option == "banner")
>| {
>| echo("<a href='" . $mylist[$picker][0] . "'><img alt='" . $mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>");
Step 3. Insert appropriate code depending upon the flag
echo "<a href='" . $mylist[$picker][0] . "'";
if( $mylist[$picker][0] == true ) {
echo " target='_blank'";
}
//--- finish of the rest of the HTML
echo "><img alt='" . $mylist[$picker][1] . "' src='" .
$mylist[$picker][2] . "' /></a>";
>| }
>|
>| else
>| {
>| echo("Error deciding option.");
>| exit();
>| }
>|
>| //Created by James Barnsley. All rights reserved.
>|
>| ?>
-- -------------------------------------------------------------
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
-- -------------------------------------------------------------
Navigation:
[Reply to this message]
|