Reputation: 47
I am making a table that shows some data and I have it in a while where the data from the database is taken. the problem is that I need a form tag for each of the tr to be able to take the data later, this works in all but not in the first field. Code:
while ($fila=mysqli_fetch_row($resultado)){
$user_name = $fila[0];
//echo '<script>alert("'.$user_name.'");</script>';
$last_name = $fila[1];
$email1 = $fila[2];
$id = $fila[3];
echo '<form id="update_user'.$id.'" name="update_user'.$id.'" action="" method="post">';
echo '<tr>';
echo '<td class="quit_click" id="nombre'.$id.'"><input id="innombre'.$id.'" name="innombre" type="text" value="'.$last_name.'"/></td>';
echo '<td class="quit_click" id="user'.$id.'"><input id="inuser'.$id.'" name="inuser" type="text" value="'.$user_name.'"/></td>';
echo '<td class="quit_click" id="email'.$id.'"><input id="inemail'.$id.'" name="inemail" type="text" value="'.$email1.'"/></td>';
echo '<td class="quit_click" id="pass'.$id.'"><input id="inpass'.$id.'" name="inpass" type="text" value="********"/></td>';
echo '</tr>';
echo '</form>';
}
In all fields it shows the form and the tr minus in the first one that only shows the content of the tr, does anyone know why? If more code is needed, tell me
Thank you.
Upvotes: 0
Views: 341
Reputation: 2666
Please dont break the html structure, table tag should be followed with thead, tr and td so form shouldnot come in between. I cannot identify the issue without seeing the full code But Can you check by adding the table fully inside the form as given below
while ($fila=mysqli_fetch_row($resultado)){
$user_name = $fila[0];
$last_name = $fila[1];
$email1 = $fila[2];
$id = $fila[3];
echo '<form id="update_user'.$id.'" name="update_user'.$id.'" action="" method="post">';
echo '<table>';
echo '<tr>';
echo '<td class="quit_click" id="nombre'.$id.'"><input id="innombre'.$id.'" name="innombre" type="text" value="'.$last_name.'"/></td>';
echo '<td class="quit_click" id="user'.$id.'"><input id="inuser'.$id.'" name="inuser" type="text" value="'.$user_name.'"/></td>';
echo '<td class="quit_click" id="email'.$id.'"><input id="inemail'.$id.'" name="inemail" type="text" value="'.$email1.'"/></td>';
echo '<td class="quit_click" id="pass'.$id.'"><input id="inpass'.$id.'" name="inpass" type="text" value="********"/></td>';
echo '</tr>';
echo '</table>';
echo '</form>';
}
Upvotes: 1