Results 1 to 3 of 3

Thread: Easy Fake TGP in PHP

  1. #1
    retrograde
    Guest

    Easy Fake TGP in PHP

    I had a site on which I wanted to include random thumbnails linking to galleries from a list of possible choices, without any duplicates showing up.

    So, I turned to PHP which made this task insanely easy (of course!).

    Anyway, I wanted to share how I did it in hopes that it'll be of use to some of you that are new to PHP.

    Note: This method can be used anytime you want random rotation of text, HTML, or images.

    Brief Explaination: I created an array containing the HTML for all the images I wanted to show up. I applied the shuffle function to that array to randomize the order, and I inserted the HTML into my page by just echoing the various values in the array where I wanted them.

    Example:

    First, I create the array with the HTML values I want to randomly show up.

    $faketgp[0] = "<a href=\"URL TO GALLERY\" target=\"_blank\"><img src=\"PATH TO IMAGE\" border=\"0\" ></a>";
    $faketgp[1] = "<a href=\"URL TO GALLERY\" target=\"_blank\"><img src=\"PATH TO IMAGE\" border=\"0\" ></a>";
    $faketgp[2] = "<a href=\"URL TO GALLERY\" target=\"_blank\"><img src=\"PATH TO IMAGE\" border=\"0\" ></a>";

    After that, I simply use PHP's handy dandy shuffle function to mix the values up!

    shuffle($faketgp);

    That was it! Now, I just insert additional code in my page to note where I want the images to show up.

    <? echo $faketgp[0]; ?>
    <? echo $faketgp[1]; ?>
    <? echo $faketgp[2]; ?>

    Each location in my page that has one of those lines will display one of the possible images and links. The order will be different each time the page is refreshed.

    Note that you'll have to make sure the numbers are different, if there are duplicates they'll display the same image. You can always have more possible values than values you actually use in your page - this is actually better because having lots of possible values decreases the chance a visitor will see the same thing too often.

    To me, this method of manually putting in each instance of an image is easier than some of the other ways I've seen the same sort of thing done.

    One problem with this that comes to mind off hand, is that the images are displayed randomly EVERY time. That means some visitors might just keep hitting refresh to see different galleries.

    Also, you can easily modify these basic pieces to make more complex and sophisticated display and rotation scripts.


  2. #2
    You do realize by 'gay' I mean a man who has sex with other men?
    Join Date
    Oct 2003
    Location
    New Orleans, Louisiana.
    Posts
    21,635
    Great stuff thanks for taking the time to share this information with us :groovy:

    Regards,

    Lee


  3. #3
    If homosexuality is a disease, let's all call in queer to work. procam's Avatar
    Join Date
    Mar 2004
    Posts
    317

    http://tgp.retrograde.org

    I surely hope that you are not planning to do such a thing on http://tgp.retrograde.org/

    Cause I would hate to have to rain on you like a Georgia thunderstorm!!!
    :wacko:

    Retro why would you post such a thing up here man to make it easy for the F-nut cheaters who wanna spoof tgps - what were u thinkin man?
    Like there arent enuf cheaters around - lets make it EASY for them now!!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •