• Hi guys,

    I would like to gather the data that is stored in wp_postmeta table under meta_key column and put it in variable, so I can manipulate it later. But I don’t hava idea how would be the SQL command for that.

    Please, a little help here.

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter Old

    (@zilli)

    It’s like this:

    database ‘wordpress’ ->
    table ‘wp_postmate’ ->
    column ‘meta_key’ with value ‘data9’
    column ‘meta_value’ with value ‘Brazil’

    So, the info that I want to get is on ‘meta_value’ column.

    Okay.

    But I’m suggesting the reason you are getting an empty return is because you don’t have any database tables in your wp_postmeta table which matches the criteria we are searching for.

    First, before we proceed, make sure you have a database entry in the table wp_postmeta which has a column ‘meta_key’ value of “data7″… or “data9” using your example above.

    Thread Starter Old

    (@zilli)

    Double checked. I have all the entries.

    Thread Starter Old

    (@zilli)

    Hi Josh,

    I got it now ??

    <?php
    $my_data = $wpdb->get_var( $wpdb->prepare(
    	"
    		SELECT (meta_value)
    		FROM $wpdb->postmeta
    		WHERE meta_key = 'data7'
    	"
    ) );
    echo "<p>My data is $my_data</p>";
    ?>

    My next step is to put this in a loop. I want to create a matrix 5×5. Anyway, thank you very much.

    Cheers,

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Database guru wanted! How to get data from wp_postmeta column meta_key?’ is closed to new replies.