Legendary_003
New member
Hello...
I-m trying to do the following !!
Listing data in the table !!
I would like....if the list has 4 rows..whetever the ID list is..make the ID list 1 2 3 4 !!
Example.....if have a list with ID 1 3 3...make stay 1 2 3 !!
Follow the try next:
echo "<table class='tabela_dados' border='1'>
<tr>
<td>ID</td>
<td>Nome Empresa</td>
<td>Responsável</td>
<td>Telefone 1</td>
<td>Telefone 2</td>
<td>E-mail 1</td>
<td>E-mail 2</td>
<td>Endereço</td>
<td>CEP</td>
<td>Bairro</td>
<td>AÇÃO 1</td>
<td>AÇÃO 2</td>
</tr>
";
$sql = "SELECT ID FROM usuarios_dados WHERE Usuario='$usuario'";
$result = $conn->query($sql);
$num_rows = $result->num_rows;
$Novo_ID = 1;
for ($i = 0; $i < $num_rows; $i++) {
$registro = $result -> fetch_row();
$sql2 = "UPDATE usuarios_dados SET ID='$Novo_ID' WHERE ID='$Novo_ID'";
$result2 = $conn->query($sql2);
$Novo_ID++;
}
$sql = "SELECT * FROM usuarios_dados";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr>
<td>$row[ID]</td>
<td>$row[Nome_Empresa]</td>
<td>$row[Responsavel]</td>
<td>$row[Telefone_1]</td>
<td>$row[Telefone_2]</td>
<td>$row[Email_1]</td>
<td>$row[Email_2]</td>
<td>$row[Endereço]</td>
<td>$row[CEP]</td>
<td>$row[Bairro]</td>
<td>
<form method='post' action='Editar_Dados.php'>
<input type='hidden' name='usuario' value='$usuario'>
<input type='hidden' name='senha' value='$senha'>
<input type='hidden' name='ID' value='$row[ID]'>
<input type='submit' style='padding: 10px;' value='EDITAR'>
</form>
</td>
<td>
<form method='post' action='Deletar_Dados.php'>
<input type='hidden' name='usuario' value='$usuario'>
<input type='hidden' name='senha' value='$senha'>
<input type='hidden' name='ID' value='$row[ID]'>
<input type='submit' style='padding: 10px;' value='DELETAR'>
</form>
</td>
</tr>
";
}
} else {
echo "0 results";
}
$conn->close();
I-m trying to do the following !!
Listing data in the table !!
I would like....if the list has 4 rows..whetever the ID list is..make the ID list 1 2 3 4 !!
Example.....if have a list with ID 1 3 3...make stay 1 2 3 !!
Follow the try next:
echo "<table class='tabela_dados' border='1'>
<tr>
<td>ID</td>
<td>Nome Empresa</td>
<td>Responsável</td>
<td>Telefone 1</td>
<td>Telefone 2</td>
<td>E-mail 1</td>
<td>E-mail 2</td>
<td>Endereço</td>
<td>CEP</td>
<td>Bairro</td>
<td>AÇÃO 1</td>
<td>AÇÃO 2</td>
</tr>
";
$sql = "SELECT ID FROM usuarios_dados WHERE Usuario='$usuario'";
$result = $conn->query($sql);
$num_rows = $result->num_rows;
$Novo_ID = 1;
for ($i = 0; $i < $num_rows; $i++) {
$registro = $result -> fetch_row();
$sql2 = "UPDATE usuarios_dados SET ID='$Novo_ID' WHERE ID='$Novo_ID'";
$result2 = $conn->query($sql2);
$Novo_ID++;
}
$sql = "SELECT * FROM usuarios_dados";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr>
<td>$row[ID]</td>
<td>$row[Nome_Empresa]</td>
<td>$row[Responsavel]</td>
<td>$row[Telefone_1]</td>
<td>$row[Telefone_2]</td>
<td>$row[Email_1]</td>
<td>$row[Email_2]</td>
<td>$row[Endereço]</td>
<td>$row[CEP]</td>
<td>$row[Bairro]</td>
<td>
<form method='post' action='Editar_Dados.php'>
<input type='hidden' name='usuario' value='$usuario'>
<input type='hidden' name='senha' value='$senha'>
<input type='hidden' name='ID' value='$row[ID]'>
<input type='submit' style='padding: 10px;' value='EDITAR'>
</form>
</td>
<td>
<form method='post' action='Deletar_Dados.php'>
<input type='hidden' name='usuario' value='$usuario'>
<input type='hidden' name='senha' value='$senha'>
<input type='hidden' name='ID' value='$row[ID]'>
<input type='submit' style='padding: 10px;' value='DELETAR'>
</form>
</td>
</tr>
";
}
} else {
echo "0 results";
}
$conn->close();