PDA

View Full Version : if problem?



techker
09-30-2008, 01:51 PM
hey guys im trying to output something if a querry is empty?



<?php
$QQQ4 = mysql_query(" SELECT *
FROM `tests`
LIMIT 0 , 30 ");

if(mysql_num_rows($QQQ4) == 0)
{
$QQQ4 = 'to come';
}



i have this done but it does not work?whats wrong with it?

if it empty it gives me

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in url on line 37

techker
09-30-2008, 02:20 PM
ok i found this in the manuel


$q = "SELECT * FROM tests";
$res = mysql_query($q);
$row = mysql_fetch_assoc($res);
echo (empty($row['d'])? "empty": "not empty");

works great but i want it to echo the content if there is not not empty

gpigate
09-30-2008, 04:23 PM
try this


<?php
$QQQ4 = mysql_query(" SELECT *
FROM `tests`
LIMIT 0 , 30 ");

if(!mysql_num_rows($QQQ4))
{
$QQQ4 = 'to come';
}

techker
09-30-2008, 07:12 PM
i got it going with this.the only think is that it links the empty to...

[code]
$q = "SELECT * FROM tests";
$res = mysql_query($q);
$row = mysql_fetch_assoc($res);


<a href="events.php?id=<?php echo $row['id'] ?>"target="_blank"><? echo (empty($row['evenement'])? "A venir": $row['evenement']);
?></a>