How to retrieve a specific information within this array?

-3

I made a SQL query in the WordPress database that returned all the information regarding a request, however I need to store some of this information in variables and I do not know how to do it.

$pid returns the ID of requests identified by post_type = shop-order in the wp_posts table. I made a foreach by sending the $pid obtained to the wp_postmeta table in order to retrieve all the information of all the requests.

Follow the code:

$sqlSelect = "SELECT * FROM wp_posts WHERE post_type = 'shop_order'";

$pid = array();
foreach ($wpdb->get_results($sqlSelect) as $ids) {
    $pid[] .= $ids->ID;
}

foreach ($pid as $uid) {
    $sqlCompr = "SELECT * FROM wp_postmeta WHERE post_id = '$uid'";
    foreach ($wpdb->get_results($sqlCompr) as $infos) {
        echo $infos->meta_key .' - '. $infos->meta_value . "<br>";
    }
    echo "<br>";
}

This code returns me the following values:

How can I store in a variable for example the value of the zip , type ...

$cep = meta_value['_billing_postcode'] // output -> 79037-090;
    
asked by anonymous 22.01.2016 / 21:06

1 answer

0
If ($infos->meta_key=="_billing_postcode")$cep=$infos->meta_value;

This within foreach

;)

    
23.01.2016 / 01:18