Hi I have this working for the query to output the result but the if zero results echo is not working, and I cnat see why, if anyone can help please, there is no error that comes up and to test there is nothing in the database table, it works when there is something in and echos out the result but not when the result is 0

$result = mysql_query("whatever query") or trigger_error(mysql_error().$sql);
while($row = mysql_fetch_array($result)){
 if(mysql_num_rows($result)==0) 
{
  echo 'there is none....';
  }     
    else
echo 'my stuff that works';
}

You should put the if on the outside like this:

$result = mysql_query("whatever query") or trigger_error(mysql_error() . $sql);
if (mysql_num_rows($result) == 0) 
{
    echo 'there is none....';
}
else
{
    while($row = mysql_fetch_array($result))
    {
        echo 'my stuff that works';
    }
}

still does not echo the result zero im afraid

Sorry my fault i did something wrong from your info... thanks for that info

Also if i want to echo $txt1 $txt2 in that ($result)==0 echo what format would they have to be in please eg at the moment i have

echo '$txt1 $txt2...';

but the result just echos $txt1 $txt2... onto the page rather than what they should

Its ok thanks i sorted it with ' . $txt1 . ' ' . $txt2 . '

Thanks for your help resolving the original problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.