Friday, January 22, 2016

PHP MYSQL: Display Data in Tables From Database

STUDENT










First you construct  your HTML code and insert the following code between your body code.

HTML, PHP and MySQL Code
<table> 
<tr> 
<th>ID #</th> 
<th>Last Name</th> 
<th>First Name</th> 
</tr> 
<?php 
$con = mysqli_connect("localhost","root","","elearning"); 
// Check connection if (mysqli_connect_errno())  
{  
echo "Failed to connect to MySQL: " . mysqli_connect_error(); 

$result=mysqli_query($con,"select * from student order by stud_last")or die(mysqli_error());
while($row=mysqli_fetch_array($result)){
?>
<tr>
<td><?php echo $row['stud_id'];?></td>
<td><?php echo $row['stud_last'];?></td>
<td><?php echo $row['stud_first'];?></td>
</tr>
<?php }?>
</table>

Output


PHP MYSQL: Display Data in Tables From Database

PHP MYSQL: Display Data in Tables From Database Rating: 4.5 Diposkan Oleh: Emoblazz

0 comments:

Post a Comment