Thursday, October 1, 2015

Wordpress-Using wpdb to connect to a separate database

$mydb = new wpdb('username','password','database','localhost');
$rows = $mydb->get_results("select Name from my_table");
echo "<ul>";
foreach ($rows as $obj) :
   echo "<li>".$obj->Name."</li>";
endforeach;
echo "</ul>";

2 comments :

  1. How to integrate social login and sharing on my Magento e-commerce site?
    Magento Modules

    ReplyDelete
  2. I have to say this has been probably the most helpful posts for me. Please keep it up. I cant wait to read whats next.
    wordpress calendar

    ReplyDelete