Support » Plugins » Error with $wpdb->get_results in foreach

  • I have the following code and it works ok, but it doesn’t print the variables $equipos->e1 and e2 or are empty or something else.

    global $wpdb;
    $sql=”SELECT user, partido, opcion FROM “. $wpdb->prefix .”liga_pujas”;
    $result=$wpdb->get_results($sql);
    echo ‘User——-Partido———-Puja
    ‘;
    foreach($result as $result){
    $sql=”SELECT e1 ,e2 FROM “. $wpdb->prefix .”liga_partidos WHERE id='”. $result->partido .”‘”;
    $equipos=$wpdb->get_results($sql);
    echo $result->user .’——-‘. $equipos->e1 .’ VS ‘. $equipos->e2 .’———-‘ . $result->opcion . ‘
    ‘;
    }

  • The topic ‘Error with $wpdb->get_results in foreach’ is closed to new replies.