.


Divya

How to retrieve data from MySql database in Wordpress


Retrieve data from MySql database in Wordpress is very easy.

<table border="1">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Points</th>
</tr>
<?php
global $wpdb;
$result = $wpdb->get_results ( "SELECT * FROM studentData" );
foreach ( $result as $print ) {
?>
<tr>
<td><?php echo $print->firstname;?></td>
<td><?php echo $print->lastname;?></td>
<td><?php echo $print->cityname;?></td>
</tr>
<?php
}
?>
</table>


.