I have this code in PHP:

$sql = mysql_query("select * from peoplebase where FName like '%$fname%' AND MName like '%$mname%' AND LName like '%$lname%' AND street like '%$street%' AND city like '%$city%' AND state like '%$state%' and zip like '%$zip%' and ssn like '%$ssn%'");

while ($row = mysql_fetch_array($sql)){
    echo "<div style='text-align:center'><h3>Results:</h3></div>";
    echo "<div style='text-align:center'><p>First Name:   ".$row['FName']."</p></div>";
    echo "<div style='text-align:center'><p>Middle Name:  ".$row['MName']."</p></div>";
    echo "<div style='text-align:center'><p>Last Name:   ".$row['LName']."</p></div>";
    echo "<div style='text-align:center'><p>Street:   ".$row['Street']."</p></div>";
    echo "<div style='text-align:center'><p>City:   ".$row['City']."</p></div>";
    echo "<div style='text-align:center'><p>State:   ".$row['State']."</p></div>";
    echo "<div style='text-align:center'><p>Zip:   ".$row['Zip']."</p></div>";
    echo "<div style='text-align:center'><p>SSN:   ".$row['SSN']."</p></div>";
    }

and I want to show these all echos in HTML in a table, Please help me fast.
Thanx, in advance

I want to show these all echos in HTML in a table

So what have you tried? I assume you know the HTML markup for a table, so changing the div's shouldn't be too difficult.

Check out http://www.w3schools.com/html/html_tables.asp
You're looking for html like this:

<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>

in your php loop it would be like;

echo "<table border=1>";
echo "<tr>";
echo "<td> style='text-align:center'><h3>Results:</h3></td>";
echo "</tr>";
while ($row = mysql_fetch_array($sql)){
    echo "<tr>";
    echo "<td style='text-align:center'>First Name:   ".$row['FName']."</td>";
    echo "<td style='text-align:center'>Middle Name:  ".$row['MName']."</td>";
    echo "<td style='text-align:center'>Last Name:   ".$row['LName']."</td>";
    echo "<td style='text-align:center'>Street:   ".$row['Street']."</td>";
    echo "<td style='text-align:center'>City:   ".$row['City']."</td>";
    echo "<td style='text-align:center'>State:   ".$row['State']."</td>";
    echo "<td style='text-align:center'>Zip:   ".$row['Zip']."</td>";
    echo "<td style='text-align:center'>SSN:   ".$row['SSN']."</td>";
    echo "</tr>";
    }
echo "</table>";
commented: thanx +0

Simply remove the echos on the displays, for instance;

echo "<div style='text-align:center'><h3>Results:</h3></div>";

will be;

<div style='text-align:center'><h3>Results:</h3></div>

Thank you all the answer is:

echo "<table width='800' cellpadding='5' cellspacing='5' border='3 solid #BDBDBD' align='center' text-align='left' rules='all'>";
echo "<tr style='background-color:#848484;'><th>First Name</th><th>Middle Name</th><th>Last Name</th><th>Street</th><th>City</th><th>State</th><th>Zip</th><th>SSN</th><th>Employment</th></tr>";
while ($row = mysql_fetch_array($sql)){
    //depending on your own parameters of course, but the values must be in single quotes
    //you can do this for as many rows as you like
    echo "<tr style='background-color: #F2F2F2'><td>".$row['FName']."</td><td>".$row['MName']."</td><td>".$row['LName']."</td><td>".$row['Street']."</td><td>".$row['City']."</td><td>".$row['State']."</td><td>".$row['Zip']."</td><td>".$row['SSN']."</td><td>".$row['Employment']."</td>";

    //this ends your table
    }
echo "</table>";
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.