abcd abcd - 1 year ago 82
PHP Question

display static values inside table in php while

We are using below code to display table , here id , name , email are not displaying inside table , but i wanted to include those inside table

enter image description here

PHP + html

$c1 = $c2 =$c3 = "";
while($data = $stmt->fetch())
$c1 .= "<td> {$data['userID']} </td>" ;
$c2 .= "<td> {$data['name']} </td>";
$c3 .= "<td> {$data['email']} </td>";
echo "<table>
<tr> ID $c1</tr>
<tr> name $c2</tr>
<tr> email $c3</tr>


tr { display: block; float: left; }
th, td { display: block; }
.table, th, td
border: 1px solid black;
color : blue;
padding: 10px;

I tried this code too , but still same result :
$c1 .= " ID2 <td> {$data['userID']} </td>" ;

Note: I really tried too much before posting question....

Answer Source

Here's what you code should be:

echo "<table>";
echo "<tr>
while($data = $stmt->fetch())
    echo "<tr>
        <td>" . $data['userID'] . "</td>
        <td>" . $data['name'] . "</td>
        <td>" . $data['email'] . "</td>
echo "</table>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download