antiblock
https://arwen2.global/
  • Chatbox

    You don't have permission to chat.
    Load More
Sign in to follow this  
є๔ฬเภ5ς

[Duvida] Carregar Dados Mysql Para Textbox

3 posts in this topic

Estou aqui com um problema, pretendia que quando o utilizador seleciona-se no dropdown o ID, ele mostrasse nas textbox a informação relativa a essa ID, o que não está a fazer é por a informação nas textbox, se conseguirem dar uma ajuda agradecia.

<?php

$servername = "localhost";

$username = "estgv15592";

$password = "estgv155922016";

$dbname = "estgv15592";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

}

$sql = "SELECT * FROM FICHA_DE_OBRA";

$result = $conn->query($sql);

echo '<form id="form" method="post">';

echo "<select name ='id'>";

echo "<option value=''>Selecione Número ficha Obra</option>";

while($row = mysqli_fetch_array($result))

{

echo "<option value='" . $row['ID_FICHAOBRA'] . "'>" . $row['ID_FICHAOBRA'] . "</option>";

}

echo "</select>";

$conn->close();

?>

<?php

if(isset($_POST["loadbtn"]))

{

$id = (integer) $_POST["id"];

$query = "SELECT NOME, MORADA, PRECO FROM FICHA_DE_OBRA WHERE ID_FICHAOBRA = '$id' ";

$result = mysql_query($query, $conn);

$details = mysql_fetch_array($result);

$nome = $details["NOME"];

$morada = $details["MORADA"];

$preco = $details["PRECO"];

}

?>

<input type="submit" value="Load" name="loadbtn">

<table width="300" border="0">

<tr>

<td>Name</td>

<td><input type="text" name="Name" style="text-align:right" value="<? echo $nome; ?>" /></td>

</tr>

<tr>

<td>Cost</td>

<td><input type="text" name="address" style="text-align:right" value="<? echo $morada; ?>" /></td>

</tr>

<tr>

<td>Active</td>

<td><input type="text" name="Price" style="text-align:right" value="<? echo $preco; ?>" /></td>

</tr>

</table>

</div>

<br/>

</form>

Share this post


Link to post
Share on other sites
antiblock
https://i.imgur.com/aJ17bf7.gif

Porque não simplesmente usares jQuery e pedires as informações com um GET a outra pagina que é baseada a partir de um ID ou w/e?

Share this post


Link to post
Share on other sites

Acho que só com PHP não consegues fazer isso

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this