WordPress.org

Ready to get started?Download WordPress

Forums

Using variables in wpdb calls? (4 posts)

  1. nickweb
    Member
    Posted 8 years ago #

    Hi, quick question. Im working with WPMU -but just now I have a query to do with the general WPDB calls.

    I have a query that pulls the blog_id from the blogs table. I then go into a loop. In that loop, I want to use a query similar to:

    $wpdb->query("SELECT * FROM {$wpdb->$VARIABLE_posts}");

    Basically the variable is passed from the first query (say the number 4). It should then be dumped into the second query, so that the second query turns out to be:

    $wpdb->query("SELECT * FROM {$wpdb->4_posts}");

    but its just now happening. Am I trying too hard and theres a simple way of doing it? Or am I missing something else?

    Thanks in advance for the help!

    Nick
    http://www.thissite.co.uk/stats

  2. nickweb
    Member
    Posted 8 years ago #

    anyone? sorry to bump - but im scratching my head here! :)

    Nick

  3. Phunky
    Member
    Posted 8 years ago #

    Erm, are you trying to pass the same $var to each query? or are you trying to pass the result from the first query into the second query?

  4. nickweb
    Member
    Posted 8 years ago #

    i have one query that grabs the variable
    the second query (above) uses that variable
    it then loops back to the first query and repeats it..

    Nick

Topic Closed

This topic has been closed to new replies.

About this Topic