我有一张桌子,我必须用查询结果填充他。其中一行是组的名称。我在while内的result3是一个查询,我得到了组的名称。我想把这个名字放在每一行。但由于某种原因,我只能得到查询结果的第一个位置。你能帮助我吗? 这是我的result3变量查询(以恢复的方式):
$sql3 = "SELECT * from titulogrupo where idutilizador ={$_SESSION['id_utilizador']}";
$result3 = mysqli_query(mysqli_connect(", "u518178166_serra"), $sql3);...etc etc...
<table table id= "myTable" class="table table-hover"> <br>
<thead>
<tr>
<th>Os meus Chips</th>
<th>NIF</th>
<th>Marca de Exploracao</th>
<th>Marca do Auricular</th>
<th>Data de Nascimento</th>
<th>Observacoes</th>
<th>Estado</th>
<th>Data1</th>
<th>Data2</th>
<th>Data3</th>
</tr>
</thead>
<?php
while ($row = mysqli_fetch_array($result)){
?>
<tr>
<td><?php echo $row['numerochip'];?><input style="float: left; margin: 0 5px;" type="checkbox" value="<?php echo $row['numerochip']; ?>" name="numero[]" id="numero"></td>
<td><?php echo $row['NIF']; ?></td>
<td><?php echo $row['MarcaExploracao']; ?> </td>
<td><?php echo $row['MarcaAuricular']; ?> </td>
<td><?php echo $row['Data_Nascimento']; ?> </td>
<td><?php echo $row['observacoes'];?>
<div class="w3-container" id="....kli..">
<input style="display: none; type="text" id="numerochipescondido" name="numerochipescondido" value="<?php echo $row['numerochip']; ?>">
<input style="display: none; type="text" id="observacoesescondido" name="observacoesescondido" value="<?php echo $row['observacoes']; ?>">
<input style="display: none; type="text" id="idutilizadorescondido" name="idutilizadorescondido" value="<?php echo $_SESSION['id_utilizador']; ?>">
<center>
<button type="button" id="<?php echo $row['numerochip']; ?>" onclick="document.getElementById('id111').style.display='block'" class="glyphicon glyphicon-pencil changeobervations" width:50px height:50px;"></button>
</center>
</div>
</td>
<td>
<?php
if($row['velha']){
echo 'Velha ';
}
if($row['prenha']){
echo 'Prenha ';
}
if($row['refugo']){
echo 'Refugo ';
}
if($row['grupo4']){
while ($row = mysqli_fetch_array($result3)){
echo $row['titulogrupo'];
}
}
?>
</td>
<td><?php echo $row['Data1']; ?> </td>
<td><?php echo $row['Data2']; ?> </td>
<td><?php echo $row['Data3']; ?> </td>
</tr>
<?php } ?>
</table>
<br>
<input type="submit" class="btn btn-warning"name="submit_x" value="Submeter Lista de Animais a Encontrar(Individual)"> <br> <br>
<input type="submit" class="btn btn-danger"name="submit_y" value="Eliminar Animais Selecionados(Individual)"> <br> <br>
<form action="deletedb.php" method="post">
<input type="submit" class="btn btn-danger"name="submit_d" value="Apagar a minha lista total">
</form>
</form>
<br>
</br>
<table class="table table-hover" style="width:300px">
<thead>
<tr>
<th>Os meus Chips a encontrar</th>
</tr>
</thead>
<?php
while ($row = mysqli_fetch_array($result2)){
?>
<tr>
<td><?php echo $row['ovelhas'];?></td>
</tr>
<?php } ?>
<!-- Começa aqui o apagar -->
<form action="apagarOvelhasEncontrar2.php" method="post">
<br>
<tr>
<td>
<button type="submit" name="submit_x" class="btn btn-danger">Apagar Ovelhas a Encontrar</button>
</td>
</tr>
</form>
</table>
</br>
</div>
答案 0 :(得分:0)
在获取$ result3等时使用其他变量
if($row['grupo4']){
while ($row3 = mysqli_fetch_array($result3)){
echo $row3['titulogrupo'];
}