Jump to content

Legendary_003

New Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Legendary_003

  1. Hello people, everything all right ?? I am with the following doubt, hope you can help me !! In my "mysql" database I have a list with ID = 1, 3 and 4 and I would like to list them in "html<select><option></option></select>" !! I can´t list them like: $sql_list = "SELECT * FROM dados_socios WHERE usuario = '$usuario' ORDER BY ID"; $result_list = $conn->query($sql_list); echo "<select>"; for($x = 0; $x <= $result_list->num_rows; $x++) { echo "<option>ID: $x</option>"; } echo "</select>"; Because if I list this way would show: ID: 1 ID: 2 ID: 3 And I would like the original: ID: 1 ID: 3 ID: 4 How Can I do that ?? Waiting answer and thanks for the attention !! One hug
  2. I got the answer: $sql = "SELECT * FROM usuarios_dados WHERE Usuario='$usuario'"; $result = $conn->query($sql); $num_rows = $result->num_rows; for ($i = 1; $i <= $num_rows; $i++) { $registro = $result -> fetch_assoc(); $sql2 = "UPDATE usuarios_dados SET ID='$i' WHERE ID='$registro[ID]' AND Usuario='$usuario'"; $result2 = $conn->query($sql2); } $sql = "SELECT * FROM usuarios_dados WHERE Usuario='$usuario'"; $result = $conn->query($sql);
  3. 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();
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.