Greetings. I have a table html which fills dinamicamente from a table mysql. This table html has three columns being the information of the last one a checkbox. From this table I must fill other one spending only the lines that are checkeadas. The button that must do the mailing of the information is a button of type submit. The second table fills from the same table mysql only that the information is alone those that correspond with be checked in the first table html. In particular the code of the first table is the following one:
<table id="tabla3" name="tabla3" border = 1 cellspacing = 1 cellpadding = 1 onclick="Contar()" > <tr><th>Cod</th><th>Diagnosticos</th><th></th> </tr>
<?php
$link = mysqli_connect("localhost", "root", "", "Consulta") or die ('Error de conexion: ' . mysqli_error());
$result= mysqli_query($link,"SELECT CODIGO, DIAG FROM POOLDIAGNOSTICOS");
while($row = mysqli_fetch_array($result)){
echo " <tr><td>".$row[0]."</td> <td>".$row[1]."</td><td><input name='codigos' type='checkbox' value=".$row[0]." /></tr>";
}
echo "</table>";
?>
The code of button is:
<input type="submit" value="Agregar diagnostico" ></input>
The code of the table html that receives the information is the following one:
<table id="tabla4" name="tabla4" border = 1 cellspacing = 1 cellpadding = 1 > <tr><th>COD</th><th>Diagnosticos1</th></tr>
<?php
$tempo4 = isset($_POST['nfilas']) ? $_POST['nfilas'] : null;
$rboton = isset($_POST['codigos']) ? $_POST['codigos'] : null ;
$chbox = array('codigos');
$result= mysqli_query($link,"SELECT CODIGO, DIAG FROM POOLDIAGNOSTICOS WHERE CODIGO='$rboton'");
for ($i=1; $i <= $tempo4; $i++){
if (isset($_POST['codigos'])){
while($row = mysqli_fetch_array($result)){
echo " <tr><td><input type='text' name='codigos' style='width:50px;height:16px;' value=".$row[0]." ></td> <td><input type='text' style='width:300px;height:16px;' name='dxs' value=".$row[1]."></td></tr>";
}
}
}
?>
</table>
The code works but two problems happen: 1. They all do not spend the lines checkeadas, only the last one. 2. If the value of the line is, for example: ' Red apple ' only appears the first word, that is to say ' Apple '. Not because this happens. I have looked but I could not have solved this matter. Much would be grateful for the help that they could give me. Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire