samedi 29 avril 2017

Leave input with value 0 ( PHP, MySql)

I want to show the students' grades. This is what I have in prueba.php Image of web browser

And I have this on my table qualifications in my database:

Image of Database

How can I leave students who do not qualifications with an input value of 0?

This is my code of prueba.php

    <table>
    <tbody>
<?php
$connect = mysql_connect("localhost","root", "");
if (!$connect) {
die(mysql_error());
}
mysql_select_db("liceo");
$results = mysql_query("SELECT rut, nombre, apellido FROM alumnos") or die(mysql_error);
while($row = mysql_fetch_object($results)) {
$rut = $row->rut;

$results2 = mysql_query("SELECT nota FROM notas WHERE rut_alumno = '$rut' LIMIT 1");
?>
<tr>
<td><?=$row->rut?></td>
<td><?=$row->nombre?></td>
<td><?=$row->apellido?></td>
<td>

<?php
while($nota = mysql_fetch_object($results2)):
?>
<input type="text" name="pin" maxlength="2" size="2" value="<?=$nota->nota?>">
<?php
endwhile;
?>
</td>
</tr>

<?php
}
?>
</tbody>
</table>




Aucun commentaire:

Enregistrer un commentaire