wordpress - echo mysql select statement with wpdb displays NO RESULTS -
i function in plugin return data when it's called for. i'm trying result @ point. used more specific query.
function ml_results() { global $wpdb; $results = $wpdb->get_results( 'select * wp_ml_char', object ); echo "<p>your character's info {$results}</p>"; } add_shortcode('ml_return', 'ml_results');
i've had no luck returning , displaying output_type. i've tried print instead of echo. i've tested query in phpmyadmin works fine. returned "array". so, $results returns "your character's info array". var_dump works fine, that's not how data displayed. belive problem lies in wordpress code, i'm not sure part of code exactly.
your results returned in array, why, can't printed out string. actually, have set flag object, , results being returned object, containing field values records in wp_ml_char table. should try this:
function ml_results() { global $wpdb; $results = $wpdb->get_results( 'select * wp_ml_char', object ); $output = ''; foreach($results $item){ //and each field in wp_ml_char table want set in output should append $output var: $output.= $item->field_name . " "; // field_name should changed name of actual field in wp_ml_char table } echo "<p>your character's info {$output}</p>"; } add_shortcode('ml_return', 'ml_results');
one other thing bothers me actual mysql statement, haven't defined more precise condition, , query have is, return results wp_ml_char table, should add condition , limit , offset.
Comments
Post a Comment