My problem:
Every time someone click on link from database script select id and show my content:
Code: Select all
function GetRandomAd()
{
global $myDB;
$today = date('j');
$ql = "SELECT * FROM reklama WHERE today<>'$today' OR realimpr<impr OR impr=0 ORDER BY RAND() LIMIT 1";
$result = $myDB->Execute($ql) or die(GetDbError($myDB->ErrorMsg()));
$r_id = $result->Fields("aid");
$r_ad_text = $result->Fields("ad_text");
$r_today = $result->Fields("today");
$result->Close();
if ($r_id)
{
if ($today != $r_today) $ql = "UPDATE reklama SET realimpr=1, today='$today' WHERE aid='$r_id'";
else $ql = "UPDATE reklama SET realimpr=realimpr+1 WHERE aid='$r_id'";
$result = $myDB->Execute($ql) or die(GetDbError($myDB->ErrorMsg()));
$result->Close();
}
return $r_ad_text;
}
function getAd()
{
global $myDB;
global $config;
$query1 = "SELECT * FROM reklama ORDER BY aid";
$result1 = $myDB->Execute($query1) or die(GetDbError($myDB->ErrorMsg()));
$f = 0;
$Repeat1__numRows = -1;
while (($Repeat1__numRows-- != 0) && (!$result1->EOF))
{
$tmp[$f]['n'] = $f + 1;
$tmp[$f]['aid'] = $result1->Fields("aid");
$tmp[$f]['ad_text'] = $result1->Fields("ad_text");
$tmp[$f]['impr'] = $result1->Fields("impr");
$tmp[$f]['realimpr'] = $result1->Fields("realimpr");
$tmp[$f++]['today'] = $result1->Fields("today");
$result1->MoveNext();
}
$result1->Close();
return $tmp;
}
reklama - table name
aid - random id which select every time
http://utorrentz.projektas.lt/bla/edit.png
ad_text - text/image which will be showed
impr - max. image/text show per day
today - put's month day (ex. today is april 18, so it puts in this field 18)
realimpr - how many time image/text was showed today (if limit reached image/text doesn't apear, thats a impr point).
At this time script everytime select random id from aid and show it. It's possible that everytime get random id's from database but show/select not one, but them all?