while cycle inside mpdf

0

I have a report that is of notes, but by inserting this code

while($notas = mysql_fetch_assoc($r_notas)) {
     $html.='<td class="tdClass"><b>'.$notas['asignatura'].'</b></td>
             <td class="tdClass">'.$notas['nota_1'].'</td>
             <td class="tdClass">'.$notas['nota_2'].'</td>
             <td class="tdClass">'.$notas['nota_3'].'</td>
             <td class="tdClass">'.$notas['nota_4'].'</td>
             <td class="tdClass">'.$notas['nota_5'].'</td>
             <td class="tdClass">'.$notas['nota_6'].'</td>
             <td class="tdClass">'.$notas['nota_7'].'</td>
             <td class="tdClass">'.$notas['promedio'].'</td>';


              } 

It does not show me the rows of the table, I even tried doing it without variables and I did it with any text, but it does not show anything, but if I do another cycle as foreach it shows me the rows, but in this case it does not work for me cycle I believe. I do not want to put all the code, because it's a lot, but basically that line is just the problem.

    
asked by Alexi Gallegos Perez 25.01.2018 в 18:13
source

1 answer

0

I think you're using the old extension of mysql instead of using mysqli .

I take this opportunity to propose some improvement in the code:

$td_on='<td class="tdClass">';
$td_off='</td>';    
//var_dump($r_notas);
if($r_notas){
    while($notas = mysqli_fetch_assoc($r_notas)) {
     $html.=$td_on.'<b>'.$notas['asignatura'].'</b>'.$td_off.
             $td_on.$notas['nota_1'].$td_off.
             $td_on.$notas['nota_2'].$td_off.
             $td_on.$notas['nota_3'].$td_off.
             $td_on.$notas['nota_4'].$td_off.
             $td_on.$notas['nota_5'].$td_off.
             $td_on.$notas['nota_6'].$td_off.
             $td_on.$notas['nota_7'].$td_off.
             $td_on.$notas['promedio'].$td_off;
      }
    //... resto del código      
}else{

    echo "No hay datos";
}           
    
answered by 25.01.2018 / 19:25
source