0

I would like to have a banner image of size 468x60 on my website (one of my HTML pages). I have copied the PHP codes that gets banner URL and Target URL from the database.

Now, I want to load those images randomly in my HTML file. I have saved the PHP code in a file named getimg.php and it contains only the following code (the file is only this code, I don't know if it is correct wholly):

<?
$geturl = mysql_query("Select id, img, target from ".$prefix."mbanners where memid!=$userid and state=1 and imps>=1 order by lasthit asc limit 1");

    if (mysql_num_rows($geturl)>0) {
        $bannerid = mysql_result($geturl, 0, "id");
        $bannerimage = mysql_result($geturl, 0, "img");
        $bannertarget = "clickbanner.php?bannerid=".$bannerid;
        @mysql_query("Update ".$prefix."mbanners set hits=hits+1, hitstoday=hitstoday+1, imps=imps-1, lasthit=".time()." where id=$bannerid limit 1");
        return "<a target=_blank href=\"$bannertarget\"><img border=0 src=\"$bannerimage\" width=468 height=60></a>";
    }

return "<a target=_blank href=\"$defaulttarget\"><img border=0 src=\"$defaultimage\" width=468 height=60></a>";

?>

Would you please give me a few tips on how to successfully do this? I am a newbie and I have found and copied this code from a friend's website.

  • Use [DOM Document](https://www.php.net/manual/en/book.dom.php). https://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php?rq=1 – vee Dec 19 '21 at 20:06

0 Answers0