How can i call the 'key' column and make conditional statement (WHERE) with others on Wordpress WPCode Snippets
enter image description here
I have tried `
$appointment_values = $wpdb->get_results("SELECT value FROM wp_e_submissions_values WHERE submission_id = '$appointments_arr->id' AND (key = \'bs_reason\' OR key = \'bs_dateofappointment\' OR key = \'bs_time\' OR key = \'bs_pa_givenname\' OR key = \'bs_pa_contactperson\' OR key = \'bs_pa_contactpersonnum\')");
and
but nothing seems to be working, only the
submission_id = '$appointments_arr->id'` is working.
Really need some help on this one
`
<?php
$logged_in_user_ID = get_current_user_id();
if ($logged_in_user_ID == 0 || $logged_in_user_ID == 1) {
// Return Nothin开发者_Go百科g ...
return;
}
global $wpdb;
$appointments_ID = $wpdb->get_results("SELECT id, key FROM wp_e_submissions WHERE user_id = '$logged_in_user_ID'");
foreach ($appointments_ID as $appointments_arr) {
$appointment_values = $wpdb->get_results("SELECT value FROM wp_e_submissions_values WHERE submission_id = '$appointments_arr->id' AND (key = \'bs_reason\' OR key = \'bs_dateofappointment\' OR key = \'bs_time\' OR key = \'bs_pa_givenname\' OR key = \'bs_pa_contactperson\' OR key = \'bs_pa_contactpersonnum\')");
$appointment_values = $wpdb->get_results("SELECT value FROM wp_e_submissions_values WHERE submission_id = '$appointments_arr->id' AND key = 'bs_reason'");
foreach ($appointment_values as $appointment_values_arr){
echo $appointment_values_arr->value . "</br>";
}
}
?>
`
精彩评论