How can i display my search result in PHP /MYSQL while loop in a horizontal table form.?

  • Thread starter Thread starter ganda
  • Start date Start date
G

ganda

Guest
How can i display my search result in PHP /MYSQL while loop in a horizontal table form. The fieldnames are the heading and the result in the search are their corresponding value.. I saw correct result but the table is repeated many times when the result is more than 1. That's why multiple table are displayed. but i only need one table together with the fields as the heading and only the <td> table data or the actual result(s) should be displayed:


This is the needed result:

Username Password
jake09 23232
jakeee 42232

the result should be like that and not:


Username jake09
Password 23232

Username jakeee
Password 42232


while($record=mysql_fetch_assoc($result))
{
while(list($fieldname,$fieldvalue) = each ($record))
{
echo "<table border=1 >";
echo "<tr>";
echo "<td>".$fieldname.": <b>" . $fieldvalue . "</b> " . "</td>";
echo "</tr>";
echo "</table>";

}

This is the code in my second representation, and my actually my problem. maybe in looping. Please help me.. Thanks..
 
If you add LIMIT 1 to the end of your sql statement it will only get one record.

But if you need all the records in the array but only want to go through the loop once you can add break(); at the end of the loop body.
 
Back
Top