Dunc
20-07-2003, 22:25
I've written a small php script to change the banner ad on my site each time you refresh.
It does it by picking the picture location and link from a mySQL database, then echo the required HTML to display it.
$dbUserID="root";
$dbUserPassword="";
$dbServer="localhost";
$dbName="ads";
$ads_displayed = 1;
$conn = mysql_connect($dbServer,$dbUserID, $dbUserPassword) or die("Unable to connect to SQL server");
$db = mysql_select_db($dbName, $conn) or die("Unable to select database");
$query = "SELECT * FROM ads WHERE site = '$SERVER_NAME' ORDER BY RAND() LIMIT $ads_displayed";
$result = mysql_query($query, $conn);
while ($row = mysql_fetch_assoc($result)) {
$pic = ($row["url"]);}
echo $pic
That works fine, and you can see it working here (http://dunc.dyndns.org/xmb/banner.php).
If you view the source you can se what is being echo'd.
however, i'm trying to get this to display in an html page without much success. It seems a simple thing to do but it just wont work.
anyone?
It does it by picking the picture location and link from a mySQL database, then echo the required HTML to display it.
$dbUserID="root";
$dbUserPassword="";
$dbServer="localhost";
$dbName="ads";
$ads_displayed = 1;
$conn = mysql_connect($dbServer,$dbUserID, $dbUserPassword) or die("Unable to connect to SQL server");
$db = mysql_select_db($dbName, $conn) or die("Unable to select database");
$query = "SELECT * FROM ads WHERE site = '$SERVER_NAME' ORDER BY RAND() LIMIT $ads_displayed";
$result = mysql_query($query, $conn);
while ($row = mysql_fetch_assoc($result)) {
$pic = ($row["url"]);}
echo $pic
That works fine, and you can see it working here (http://dunc.dyndns.org/xmb/banner.php).
If you view the source you can se what is being echo'd.
however, i'm trying to get this to display in an html page without much success. It seems a simple thing to do but it just wont work.
anyone?