/ Published in: PHP

Refer to the following:
http://codex.wordpress.org/Class_Reference/wpdb
http://codex.wordpress.org/Class_Reference/wpdb
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* Say you created a TABLE named food in the wordpress database WITH THE COLUMNS id name organic YES/NO */ global $wpdb; $query = 'SELECT id, name, organic FROM food'; $rows = $wpdb -> get_results($query); foreach ($rows as $key=> $value) { $id = $value->id; $name = $value->name; $organic = value->organic; ?><p><?php echo $id; ?></p><?php ?><p><?php echo $name; ?></p><?php ?><p><?php echo $organic; ?></p><?php } ?>
Comments
