while ( $row = mysql_fetch_array($sql) ) 
{
echo "<table>";
}

if nothing is found in the database relating to the query

i should get like this

while ( $row = mysql_fetch_array($sql) ) 
{
if nothing is found in the database
echo "<table no results found>";
}

only if the table is empty, i should get no results found message.
otherwise the content of the table should be displayed......

$num=mysql_num_rows($sql);
if($num>0)
{
while($row=mysql_fetch_array($sql))
{
echo"<table>";
}
}
else
{
echo  "<table>"."no records here";
}

try like this. i am not sure this is working or not.

commented: Thxs!!! +1
if ($sql)
{
echo "<here are the results>";
}
while ( $row = mysql_fetch_array($sql) ) 
{
echo "<display the content in table>";
}

What i need is.........

if ($sql=empty)
{
echo "<here are the results>";
}
while ( $row = mysql_fetch_array($sql) ) 
{
echo "<table no results found>";
}

thxs!!!
@rajabhaskar525
it worked like a charm!!!!!

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.