954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help PHP database

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>";
}
tryingtofindout
Newbie Poster
20 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

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

tryingtofindout
Newbie Poster
20 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 
$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.

rajabhaskar525
Junior Poster
179 posts since Nov 2009
Reputation Points: 12
Solved Threads: 27
 
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>";
}
tryingtofindout
Newbie Poster
20 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

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

tryingtofindout
Newbie Poster
20 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: