-3
I made a query SQL in the Wordpress database that returned me all the information related to a request, but I need to store some variables of this information and do not know how to do.
The $pid
returns the ID of the applications identified by post_type=shop-order on the table wp_posts
. I made a foreach
sending the $pid
obtained for the table wp_postmeta
in order to redeem all information of all orders.
Follows 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 I can store in a variable for example the value of ZIP CODE, guy ...
$cep = meta_value['_billing_postcode'] // output -> 79037-090;
Inside the foreach has already tested to do this?
$wpdb->get_results($sqlCompr)['_billing_postcode']
?– Guilherme Lopes