Support » Plugins » can’t display data from mysql table in post

  • Hi All,

    Sorry to ask but have spend a good 5 hours working on this and no joy.

    I have set up a new table called wp_merchant_table in the wordpress database and want to pull out info from it and display in my posts.

    I have put this code into my single.php file in the hope it would get the data in the table but only get errors.
    The table has colums:
    productid – this is the product number we review
    merchant_name- eg. amazon
    country – 0 or 1
    price – err the price of the product
    affiliate_link – the link to the place to buy a product we review

    $result = $wpdb->get_results('SELECT price, merchant_name, affiliate_link FROM wp_merchant_table WHERE productid ="25"');
    if ($result) {

    while ($row = mysql_fetch_array($result)) {
    echo $row['price'];
    echo $row['merchant_name'];
    echo $row['affiliate_link'];


    I just get errors or nothing returned. Any idea why my code does not work. Alternatively if someone can tel me how to extract info from a seporate database on the same server and include into a wordpress post page that would be great also.

    Many thanks. Hope this isn’t too daft a question.


Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘can’t display data from mysql table in post’ is closed to new replies.