[PHP] Help with something to do with echo

Results 1 to 8 of 8
  1. #1
    Infraction Banned Josh is offline
    Grand MasterRank
    Dec 2004 Join Date
    8,333Posts

    [PHP] Help with something to do with echo

    Ok, basically what I am trying to do is everytime the page loads, the next thing loads.
    For example:
    Load 1: Text 1 loads
    Refresh: Text 2 loads
    Refresh: Text 3 loads

    But it can be random as well.

    Any help would be appreciated. :)


  2. #2
    Grand Master Mario_Party is offline
    Grand MasterRank
    Nov 2003 Join Date
    LondonLocation
    1,803Posts
    load the information into a session variable, failing that put it into a cookie... or even use both o_O, store it in a session variable and the cookie, so that when the user comes back to the page it is on the page they were on before.

  3. #3
    Sorcerer Supreme MrD. is offline
    Member +Rank
    Feb 2003 Join Date
    EnglandLocation
    394Posts
    Start a session and store a variable in it, then make it so every time the page gets refreshed, the variable is incremented by one.

  4. #4
    Elite Member Jackel is offline
    Member +Rank
    May 2005 Join Date
    Ontario, CanadaLocation
    104Posts
    I'm not sure, but maybe you're looking for something like this.

    PHP Code:
    <?php
     $value 
    = array(
                   
    'Text 1',
                   
    'Text 2',
                   
    'Text 3');
     
    $num rand(0,2);
     echo 
    $value[$num];
    ?>
    This is only an example ;)

  5. #5
    Infraction Banned Josh is offline
    Grand MasterRank
    Dec 2004 Join Date
    8,333Posts
    I just simply want to put ad coding into it, each time it loads it shows a random ad.

    Edit:
    Thanks anyways but i found something better. :)
    Last edited by Josh; 15-09-06 at 09:19 PM.

  6. #6
    Grand Master Mazo is offline
    Grand MasterRank
    Apr 2003 Join Date
    Not in this "out" you speak ofLocation
    2,021Posts
    Care to post what you found Josh? Ad rotation = yummies

    EDIT: By the way, you know your previous post about a login script well instead of using
    Code:
     if ($_SESSION['logged_in'] = 1) {page contents} else {echo 'not logged in'}
    you could use
    Code:
    <?
    if ($_SESSION['logged_in'] != 1)
      {
       echo "You are not logged in.";
       die();
      }
    Last edited by Mazo; 16-09-06 at 11:18 PM.

  7. #7
    Grand Master FragFrog is offline
    Grand MasterRank
    Aug 2004 Join Date
    The NetherlandsLocation
    5,629Posts
    And instead of that you should use
    Code:
    <?
    if (!$_SESSION['logged_in'])
      die("You are not logged in.");
    Learn to code efficient people! ;)

    Also, care to share here what the sollution was?

  8. #8
    Grand Master Mazo is offline
    Grand MasterRank
    Apr 2003 Join Date
    Not in this "out" you speak ofLocation
    2,021Posts
    Leave me alone frag :( im not that great at php...yet :(



Advertisement