Results 1 to 3 of 3

Thread: Simple Banner Script Javascript or PHP Advice

  1. #1
    Agent of the System ikonia's Avatar
    Join Date
    May 2004
    Location
    South West UK (Bath)
    Posts
    3,736
    Thanks
    39
    Thanked
    75 times in 56 posts

    Simple Banner Script Javascript or PHP Advice

    Hello all.

    I'm looking at a possibility of putting together a small banner advertisment script thats VERY simple for a website I'm trying to put together (none proffit - and non comercial adds, hence why I ask)

    I have some basic PHP from a CMS that creates the following code
    <table width="100%" height="68" border="0" cellpadding="0" cellspacing="0">
    <tr>

    <td width="34%" height="65" align="left" valign="middle" id="align_left"><a href="http://www.test.co.uk"><img src="img/test_logo.gif" width="228" height="54" border="0"></a></td>
    <td width="66%" align="center" valign="middle"><a href="#"><img src="img/advert.gif" width="468" height="60" border="0"></a></td>
    </tr>
    </table>

    The part that interest me is


    <td width="66%" align="center" valign="middle"><a href="#"><img src="img/advert.gif" width="468" height="60" border="0"></a></td>
    What I'm thinking, is as follows something along the lines of

    <script language="javascript">
    <!-- some javascript that loops though a flat file or something and assigns a link url to $LINK and the matching image the $IMAGE variable
    --!>
    </script>
    <td width="66%" align="center" valign="middle"><a href="$URL"><img src="$IMAGE" width="468" height="60" border="0"></a></td>
    and then

    having a config file somthing linke

    ads.config


    www.testsite1.com images/test1.gif
    www.mysite.co.uk image/mysite.gif
    www.bigbob.net images/fatty.gif
    therefore the java script would loop through and assign www.testsite1.com to $LINK and images/test1.gif to $IMAGE

    the code would then look like this


    <script language="javascript">
    <!-- some javascript that loops though a flat file or something and assigns a link url to $LINK and the matching image the $IMAGE variable
    --!>
    </script>
    <td width="66%" align="center" valign="middle"><a href="$URL"><img src="$IMAGE" width="468" height="60" border="0"></a></td>
    and then

    having a config file somthing linke

    ads.config


    www.testsite1.com images/test1.gif
    www.mysite.co.uk image/mysite.gif
    www.bigbob.net images/fatty.gif
    therefore the java script would loop through and assign www.testsite1.com to $LINK and images/test1.gif to $IMAGE

    the code would then look like this


    <script language="javascript">
    <!-- some javascript that loops though a flat file or something and assigns a link url to $LINK and the matching image the $IMAGE variable
    --!>
    </script>
    <td width="66%" align="center" valign="middle"><a href="$URL"><img src="$IMAGE" width="468" height="60" border="0"></a></td>
    and then

    having a config file somthing linke

    ads.config


    www.testsite1.com images/test1.gif
    www.mysite.co.uk image/mysite.gif
    www.bigbob.net images/fatty.gif
    therefore the java script would loop through and assign www.testsite1.com to $LINK and images/test1.gif to $IMAGE

    the code would then look like this

    <script language="javascript">
    <!-- some javascript that loops though a flat file or something and assigns a link url to $LINK and the matching image the $IMAGE variable
    --!>
    </script>
    <td width="66%" align="center" valign="middle"><a href="www.testsite.com"><img src="images/test1.gif" width="468" height="60" border="0"></a></td>

    this is only the principal I'm trying to get my head around - and I'm only using javascript as an example

    I'd be happy to do something like include a php script that connects to a database and gets the data from a database table or flat file

    such as


    select image,url from adverts
    Does anyone have any experience with this, or could someone lend a hand.

    thanks.
    It is Inevitable.....


  2. #2
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts
    The easiest way I reckon is your database method. You want a script that generates a random number, and your db's advert table should include unique_key, image and url fields. The random number would be generated and your SQL statement would read SELECT * FROM adverts WHERE unique_key = '$random_number'. Of course your limitations here are assigning a max_value to to the random_number, you could increase it's value each time you add a new image/url to the database. The best solution however is to retrieve the metadata for the 'adverts' table which would return the no of rows, using this as your max_value. Of course this is all based on you wanting the the ad's random, and not in order, or not displaying the same ad twice etc. Good luck.
    To err is human. To really foul things up ... you need a computer.

  3. #3
    Agent of the System ikonia's Avatar
    Join Date
    May 2004
    Location
    South West UK (Bath)
    Posts
    3,736
    Thanks
    39
    Thanked
    75 times in 56 posts
    funny enough this is pretty much identical to the way I went.

    I'll post the code once its finished. I just needed to look at it from a different angle

    thanks for your view
    It is Inevitable.....


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PHP script errors after moving hosts..
    By Stoo in forum Software
    Replies: 15
    Last Post: 15-07-2004, 12:31 AM

Posting Permissions

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