1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP Problem

Discussion in 'PHP & Perl' started by JB112, Dec 9, 2011.

  1. JB112

    JB112 Newbie

    Joined:
    Oct 14, 2010
    Messages:
    15
    Likes Received:
    7
    Location:
    On a long and lonesome highway, East of Omaha
    This might just be a small thing but i have no idea how to do it! I have a small bit of knowledge but not much!

    I want a "random" banner to match up with it's link

    so i want banner1 to associate with link 1 ect...

    here's the code. anyone know what i am doing wrong? The banner is appearing as i want it to but the link is coming out like mysite.c0m/1 . The number is being posted to my domain name instead of a new link being create in a "a href" tag

    Code:
    <?php
    
    $num = rand(1,4);
    $web = $num;
    if ($num == "1") {
        echo 'hxxp://vvv.xxxxxx.c0m/click-4232665-10489913?tid=1';
    } else if ($num == "2") {
        echo ' hxxp://vvv.xxxxxxxx.c0m/click-4232665-10489913?tid=2';
    } else if ($num == "3") {
        echo ' hxxp://vvv.xxxxxxxxx.c0m/click-4232665-10489913?tid=3';
    } else if ($num == "4") {
        echo ' hxxp://vvv.xxxxxxxxx.c0m/click-4232665-10489913?tid=4';
    }
    ?>
    
    //this then is where i am trying to post to....
    
    <div id="ad"><a href="<?php echo $web; ?>" target="_blank"><img src="_aImages/_images/banner<?php echo $num; ?>.jpg" width="535" height="100" /></a></div>
    
    anyone able to help?

    thanks
    JB
     
  2. JB112

    JB112 Newbie

    Joined:
    Oct 14, 2010
    Messages:
    15
    Likes Received:
    7
    Location:
    On a long and lonesome highway, East of Omaha
    It's ok i figured out what was wrong...sorry for wasting anyone's time

    if anyone is wondering just had to change the code a bit

    Code:
    <?php
    
    $num = rand(1,4);
    
    ?>
    
    <div id="ad"><a href="<?php $web = $num;
    if ($num == "1") {
        echo 'hxxp://vvv.xxxxxx.c0m/click-4232665-10489913?tid=1';
    } else if ($num == "2") {
        echo ' hxxp://vvv.xxxxxxxx.c0m/click-4232665-10489913?tid=2';
    } else if ($num == "3") {
        echo ' hxxp://vvv.xxxxxxxxx.c0m/click-4232665-10489913?tid=3';
    } else if ($num == "4") {
        echo ' hxxp://vvv.xxxxxxxxx.c0m/click-4232665-10489913?tid=4';
    }; ?>" target="_blank"><img src="_aImages/_images/banner<?php echo $num; ?>.jpg" width="535" height="100" /></a></div>
     
  3. davids355

    davids355 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 25, 2011
    Messages:
    8,776
    Likes Received:
    6,307
    Home Page:
    Well done:)
     
    • Thanks Thanks x 1
  4. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,143
    instead of
    Code:
    echo 'hxxp://vvv.xx...';
    
    do

    Code:
    $web = 'hxxp://vvv.xx...';
    
    Edit: Just noticed I was late :) Obviously this refers to the first post.
     
    • Thanks Thanks x 2
  5. JB112

    JB112 Newbie

    Joined:
    Oct 14, 2010
    Messages:
    15
    Likes Received:
    7
    Location:
    On a long and lonesome highway, East of Omaha
    thanks man!

    I just took a second to think about what was happening with the script! divine inspiration :p

    cheers anyway dude! i appreciate the help :D
     
    • Thanks Thanks x 1