From 14d2f0f5ecbfcd565f48cbf522d9d7315bec0379 Mon Sep 17 00:00:00 2001 From: alopexc0de Date: Mon, 29 Apr 2013 14:59:45 -0500 Subject: [PATCH] Added randomized ads in banner --- img/index.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/img/index.php b/img/index.php index 235569f..4872460 100755 --- a/img/index.php +++ b/img/index.php @@ -52,7 +52,25 @@ $username = ''; $tags = ''; $_SESSION['noimg'] = ''; - + + function showads(){ + // Code for ads or something... + $db = new mysqli('localhost', 'adds', 'password', 'adds'); // hostname. username, password, database + if($db->connect_errno > 0){ + die('Unable to connect to database [' . $db->connect_error . ']'); + } + + $rand = mt_rand(1, 6); + $ads = "SELECT * FROM `ads` WHERE `id` = $rand"; + + if(!$result = $db->query($ads)){ + die('There was an error running the query [' . $db->error . ']'); + } + $row = $result->fetch_assoc(); + if($row){ + return 'ad for '.$row['cname'].''; + } + } ?> @@ -152,7 +170,9 @@
- This is a placeholder for ads +