Jump to content
php.lv forumi

slect rand() nestrada ?


FT3

Recommended Posts

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 by FT3
Link to comment
Share on other sites

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 by FT3
Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...