I don't know much about SQL. I'm trying to access this information to put it in a variable.
For example, I need to take the e-mails, the two values and put them in a separate variable.
How do I make a filter to find these variables according to the email value?
$comissao_total = $wpdb->get_results("SELECT post_content FROM wp0l_posts WHERE id = 9029");
print_r($comissao_total);
The return I get is something like this.
Array(
[0] =>
[post_content] => [
["Email","D\u00e9bito","Cr\u00e9dito","Identifica\u00e7\u00e3o do Vendedor"],
["abraaop739@gmail.com","725","0","jrexpress.soares2020@gmail.com"],
["admilsondemorais@gmail.com","645.5","20",
"ygor.carvalho.nascimento@gmail.com"],
["adriano_sena1985@hotmail.com","200","0","jhony96cesar@gmail.com"],
["agromasteragro@gmail.com","21591.2","3573.2",
"ygor.carvalho.nascimento@gmail.com"]
]
))
In this case it returns the array with all the data, but in fact I would need to get only the values, via email.
For example: If I want to filter the email jrexpress.soares2020@gmail.com
, I need to receive 725 and 0 in two variables. Corresponding to this array ["abraaop739@gmail.com", "725", "0", "jrexpress.soares2020@gmail.com"]
you can write yourself a function and loop thru the array with foreach
<?php
$var1 = "";
$var2 = "";
// your input array
$yourArray['0']['post_content'] = Array( [
["Email","D\u00e9bito","Cr\u00e9dito","Identifica\u00e7\u00e3o do Vendedor"],
["abraaop739@gmail.com","725","0","jrexpress.soares2020@gmail.com"],
["admilsondemorais@gmail.com","645.5","20","ygor.carvalho.nascimento@gmail.com"],
["adriano_sena1985@hotmail.com","200","0","jhony96cesar@gmail.com"],
["agromasteragro@gmail.com","21591.2","3573.2","ygor.carvalho.nascimento@gmail.com"]
] );
// your filter function
function filter($email){
global $var1;
global $var2;
global $yourArray;
foreach($yourArray['0']['post_content'][0] as $var){
foreach($var as $val){
if($val == $email){
$var1 = $var['1'];
$var2 = $var['2'];
}
}
}
}
//calling the function
filter("jrexpress.soares2020@gmail.com");
// output
echo "<pre>";
echo "\$var1 = $var1 \n";
echo "\$var2 = $var2 \n";
echo "</pre>";
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.