Jump to content

Loading files/database on another site

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
Hi there.

I'm looking at create a site that will require people to put code on there site where it will show images and banner links, would it be possible to use a javascript like the one on this thread, and then put MySQL into it to get the links and images???

[LEFT][COLOR=#000000][FONT=Arial]<SCRIPT LANGUAGE="JavaScript">[/FONT][/COLOR][COLOR=#000000][FONT=Arial]<!-- BANNER ROTATOR[/FONT][/COLOR][COLOR=#000000][FONT=Arial]var how_many_ads = 3
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;[/FONT][/COLOR][COLOR=#000000][FONT=Arial]//***************** AD NUMBER ONE ****************[/FONT][/COLOR][COLOR=#000000][FONT=Arial]if (ad==1){[/FONT][/COLOR][COLOR=#000000][FONT=Arial]url="[COLOR=#FF0000][B]http://www.youradvertiser.com[/B][/COLOR]";[/FONT][/COLOR][COLOR=#000000][FONT=Arial]alt="[COLOR=#FF0000][B]Advertiser Number One[/B][/COLOR]";[/FONT][/COLOR][COLOR=#000000][FONT=Arial]banner="[COLOR=#FF0000][B]http://www.yourdomain.com/images/banner1.gif[/B][/COLOR]";[/FONT][/COLOR][COLOR=#000000][FONT=Arial]width="[COLOR=#FF0000][B]468[/B][/COLOR]";
height="[COLOR=#FF0000][B]60[/B][/COLOR]";
}[/FONT][/COLOR][COLOR=#000000][FONT=Arial]//***************** AD NUMBER TWO ****************[/FONT][/COLOR][COLOR=#000000][FONT=Arial]if (ad==2){[/FONT][/COLOR][COLOR=#000000][FONT=Arial]url="[COLOR=#FF0000][B]http://www.youradvertiser.com[/B][/COLOR]";[/FONT][/COLOR][COLOR=#000000][FONT=Arial]alt="[COLOR=#FF0000][B]Advertiser Number Two[/B][/COLOR]";[/FONT][/COLOR][COLOR=#000000][FONT=Arial]banner="[COLOR=#FF0000][B]http://www.yourdomain.com/images/banner2.gif[/B][/COLOR]";[/FONT][/COLOR][COLOR=#000000][FONT=Arial]width="[COLOR=#FF0000][B]468[/B][/COLOR]";
height="[COLOR=#FF0000][B]60[/B][/COLOR]";
}[/FONT][/COLOR][COLOR=#000000][FONT=Arial]//***************** AD NUMBER THREE ****************[/FONT][/COLOR][COLOR=#000000][FONT=Arial]if (ad==3){[/FONT][/COLOR][COLOR=#000000][FONT=Arial]url="[COLOR=#FF0000][B]http://www.youradvertiser.com[/B][/COLOR]";[/FONT][/COLOR][COLOR=#000000][FONT=Arial]alt="[COLOR=#FF0000][B]Advertiser Number Three[/B][/COLOR]";[/FONT][/COLOR][COLOR=#000000][FONT=Arial]banner="[COLOR=#FF0000][B]http://www.yourdomain.com/images/banner3.gif[/B][/COLOR]";[/FONT][/COLOR][COLOR=#000000][FONT=Arial]width="[COLOR=#FF0000][B]468[/B][/COLOR]";
height="[COLOR=#FF0000][B]60[/B][/COLOR]";
}[/FONT][/COLOR][COLOR=#000000][FONT=Arial]document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_blank\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('</center>');
-->
[/FONT][/COLOR][COLOR=#000000][FONT=Arial]</SCRIPT>[/FONT][/COLOR][/LEFT]


thnx

#2
Vaielab

Vaielab

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 547 posts
Yes you can do this. The only difference is that you won't be loading a .js file but a .php file with javascript in it.
Same as when you execute php to create html, you will execute php to create javascript

#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
I believe it would go like this:
<?php
  header("Content-type: text/javascript");
  // Get ad from database
  ...
  echo "<img src=$source...";
?>
<script type="text/javascript" src="http://yoursite.com/ad.php"/>

You have the added benefit of metrics, you can track whom is accessing what ad. You don't need ad.php?ad= unless you wish for Javascript to supply the ad number for whatever reason, the PHP script can do this randomness for you and it is not required.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users