Created
April 24, 2015 14:04
-
-
Save itssalman/63c659be5eedc32e22a5 to your computer and use it in GitHub Desktop.
PHP : MySQLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: SALMAN ASLAM | |
* Date: 12-Jan-15 | |
* Time: 10:26 PM | |
*/ | |
// create connection | |
$mysqli = new mysqli('localhost','root','salman','company'); | |
// check connection | |
if(mysqli_connect_errno()) | |
{ | |
print_f("Connection not successful %s\n".mysqli_connect_errno()); | |
} | |
$result = $mysqli->query("SELECT * FROM employees"); | |
?> | |
<h1>Employees</h1> | |
<table width="500px" cellpadding="5" cellspacing="5" border="1"> | |
<tr> | |
<th>ID#</th> | |
<th>First Name</th> | |
<th>Last Name</th> | |
<th>Department</th> | |
<th>Email</th> | |
</tr> | |
<?php while($row = $result->fetch_object()): ?> | |
<tr> | |
<td><?php echo $row->id; ?></td> | |
<td><?php echo $row->first_name; ?></td> | |
<td><?php echo $row->last_name; ?></td> | |
<td><?php echo $row->department; ?></td> | |
<td><?php echo $row->email; ?></td> | |
</tr> | |
<?php endwhile;?> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment