Evening,
I have piece of code:
for ($i=0; $i < $c; $i++){
$result = mysql_query("SELECT ad_id,title FROM `ads` WHERE `ad_id`='".$new[$i]."' LIMIT 10");
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)){
if(($c > 3) && ($i < 2)){
echo '
<div class="pins best">
<div class="holder">
'.$row['title'].'
</div>
</div>';
} else {
echo '
<div class="pins">
<div class="holder">
'.$row['title'].'
</div>
</div>';
}
}
} else {
echo "No results";
}
}
Now what i am doing is checking each id
which i have in $new
array with id
coresponding in db
.
What I can not accomplish is to output some message to user if there are no results matching db
records. I tried to write after an if
statement, else
statement, but it doesn't work because this db
selection is in for
loop.
Any suggestions?
EDITED: I added the else statement to my code,because everyone suggesting what I already tried, and that's where the problem is.
id
that fails in another array. See below.