I have two functions that i’m hoping i can put into one and can be called differently.
function my_function() {
global $wpdb;
foreach( $wpdb->get_results( "MYSQL QUERY" ) as $key => $row)
{
echo "'". $row->DAY . "'";
}
}
function my_function_two() {
global $wpdb;
foreach( $wpdb->get_results( "MYSQL QUERY" ) as $key => $row)
{
echo "'". $row->TIME . "'";
}
}
Notice how the only diffence between them both is the $row->TIME and $row->DAY, i’m using the exact same mysql query in both and was wondering if these two functions can be merged into one?
Thanks for help.
You can do:
If you have to echo
$row->DAY, call the function withtrueas parameter or leave it out to echo$row->TIME.Example: