Hi
I have a database and i want to display the data from the database to the php page in a tabular from. how do i go about it
the fields in the database are
1)mobile_number
2) cust_name
3 ) emp_no
any help would be appriciated
Printable View
Hi
I have a database and i want to display the data from the database to the php page in a tabular from. how do i go about it
the fields in the database are
1)mobile_number
2) cust_name
3 ) emp_no
any help would be appriciated
Ask questions if you don't understand any of it.Code:<table>
<thead>
<tr>
<td>Mobile Number</td>
<td>Customer Name</td>
<td>Employee No.</td>
</tr>
</thead>
<tbody>
<?php
//connect and select database
//query for your data
$sql_result = mysql_query("SELECT * FROM tableName ORDER BY emp_no");
//mysql_fetch_assoc() gets an associative array of the current
//row in your result set. by putting it in a while loop,
//it will continue to get each row until the end of the set.
//on each loop, $sql_row is populated with the array of the
//current row
while($sql_row = mysql_fetch_assoc($sql_result)){
?>
<tr>
<td><?php echo $sql_row["mobile_number"];?></td>
<td><?php echo $sql_row["cust_name"];?></td>
<td><?php echo $sql_row["emp_no"];?></td>
</tr>
<?php
}
?>
</tbody>
</table>