Jump to content

[SOLVED] ad management tutorial


marksie1988

Recommended Posts

ok so i have decided that if i create a table with the followint fields

 

id

customer = customers name

www = url for customer website

img = url for customer banner

shown = how many times it has been shown

show = how many times to be shown

 

then i will pull the information from the database and have an if statement as follows

 

if (show == shown ){

retry for another banner

}

 

 

but what i dont know is how can i tell it to try a different banner if the banner has reached its limit??

Link to comment
Share on other sites

ok now i have the folowing code which works great but for some reason just keeps on echoing the data i also tried print and the same happened

 

<?php 
$query = "SELECT * FROM `adsys_banner` WHERE `shown` < `show` ORDER BY RAND() LIMIT 1";
$result = mysql_query ($query);
$num = mysql_num_rows($result);

$i=0;
while ($i < $num) {

$id = mysql_result($result,$i,"id");
$cust = mysql_result($result,$i,"cust");
$show = mysql_result($result,$i,"show");
$shown = mysql_result($result,$i,"shown");
$www = mysql_result($result,$i,"www");


echo "$www"; 
}
?>

Link to comment
Share on other sites

EDIT: Wow, you beat me by fractions of a second, haha

 

It's because your using a while looop. Do this

 

<?php 
$query = "SELECT www FROM `adsys_banner` WHERE `shown` < `show` ORDER BY RAND() LIMIT 1";
$result = mysql_query ($query);
$row = mysql_fetch_assoc($result);

echo $row['www'].'<br>'; 

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.