FT3 Posted February 25, 2012 Report Share Posted February 25, 2012 (edited) Sveiski , man te atgadijusies ķibele $result = mysql_query("SELECT * FROM `banner_ad` WHERE `expire` > '$now' ORDER BY rand() LIMIT 2"); while($row = mysql_fetch_array($result)){ echo " <a href='".$row['adress']."' target='_blank'><img src='".$row['banner']."' title='".$row['title']."' width='468' height='60'></a> "; izvada tikai 1 banneri un visu laiku vienu un to pašu bet ja noņemu WHERE `expire` > '$now' tad rand() strada ;/ Edited February 25, 2012 by FT3 Quote Link to comment Share on other sites More sharing options...
briedis Posted February 25, 2012 Report Share Posted February 25, 2012 Visdrīzāk atgriež tikai 1, jo tikai viens izpilda nosacījumu expire > $now... Quote Link to comment Share on other sites More sharing options...
FT3 Posted February 25, 2012 Author Report Share Posted February 25, 2012 (edited) un ka to izlabot ? pilns kods <?php $con = mysql_connect("localhost","aaaa","aaaa"); if (!$con){die('Could not connect: ' . mysql_error());} mysql_select_db("quix_base", $con); $now = time(); if($_GET['type'] == 'banner'){ $result = mysql_query("SELECT * FROM `banner_ad` WHERE `expire` > '$now' ORDER BY rand() LIMIT 1")or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo " <a href='".$row['adress']."' target='_blank'><img src='".$row['banner']."' title='".$row['title']."' width='468' height='60'></a> "; } }else{ $result = mysql_query("SELECT * FROM `text_ad` WHERE `expire` > '$now' ORDER BY rand() LIMIT 2"); while($row = mysql_fetch_array($result)){ echo " <a target='_blank' href='".$row['url_line']."' > <div id='text_advert'> <B>".$row['bold_line']."</B> <BR> ".$row['text_line1']." <BR> ".$row['text_line2']." <BR> <b>".$row['url_line']."</b> </div> </a> "; } } mysql_close($con); ?> text_ad izvelk viss okey , bet to banner_ad neka , Edited February 25, 2012 by FT3 Quote Link to comment Share on other sites More sharing options...
briedis Posted February 25, 2012 Report Share Posted February 25, 2012 Parādi kodu, kas pievieno banneri, noteikti tur ir kļūda. Expire laikam ir jābūt lielākam(!) par $now, tad arī problēmas nebūs. Quote Link to comment Share on other sites More sharing options...
FT3 Posted February 25, 2012 Author Report Share Posted February 25, 2012 kļuda nav bannera pievienošana , jo uz localhost viss iet bet uz hosta nejiet , tikai tas text_ad , varbut vaina datubaze ? Quote Link to comment Share on other sites More sharing options...
briedis Posted February 25, 2012 Report Share Posted February 25, 2012 Ok, pateikšu vienu noslēpumu - ja tu domā, ka kļūda nav tavā kodā, bet gan PHP, datubāzē, vai kur citur, tad patiesībā kļūda ir tavā kodā. Meklē to. Sāc ar to, ka tu izdrukā visu, kas ir tajā tabulā, un pārbaudi 10x, vai tiešām tur ir tas, ko tu domāji... Quote Link to comment Share on other sites More sharing options...
FT3 Posted February 25, 2012 Author Report Share Posted February 25, 2012 tiešam pie add bija kļuda ar input value :) , tnq tev :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.