mysql - How to query database in WordPress and loop through results -
i've been used making simple pdo queries mysql this:
$query = $db->prepare("select * `my_table` order `rank`"); $query->execute(); $numrows = $query->rowcount(); while($row = $query->fetch()) { $thiscolumn = $row['value']; }
but want same using wordpress (not 1 of wordpress's own tables, 1 of own). simplest way of translating query?
global $wpdb; $query = "select * `my_table` order `rank`"; $result = $wpdb->get_results($query); foreach ($result $instance) { echo $instance->value; }
Comments
Post a Comment