Jump to content

Can't get retreived data to display in form


crmamx

Recommended Posts

I was told that I could retreive a db record and the fields would display in a form, which I could subsequently change and then update the db. If I am going about it the right way I just can't get the data to display. The echo appears to show I am getting a record.

 

form4_change_airplane.php

<html> 
<head></head>
<body> 

<?php // Connect to database=====================================================

include("connect_db.php");
$table1='passwords';
$table2='airplanes';
$amano="940276";
$id="1";

// sending query ===========================================================

$result = mysql_query("SELECT * FROM $table2
WHERE id='$id'") or die(mysql_error());  

if (!$result) {
    die("Query to show fields from table failed");
}

$num_rows = mysql_num_rows($result);
echo "$num_rows";

?>

<form action="display1_airplanes.php" method="post"> 
ID #: <input type="text" name="id" size="6">
AMA #: <input name="ama" type="text" size="6"><br>
Model Name: <input name="model_name" type="text" size="30"><br>
Model Mfg: <input name="model_mfg" type="text" size="30"><br>
Wingspan: <input name="wingspan" type="text" size="6"><br>
Engine: <input name="engine" type="text" size="30"><br>
Decibels: <input name="decibels" type="text" size="6"><br>

<input type="submit" value="Send"> 
</form> 
</body> 
</html> 

 

 

the values won't magically appear in the form fields. you have to put them there. for example:

 

ID #: <input type="text" name="id" size="6" value='<?php echo $id; ?>'>

 

you might want to start with a tutorial.

 

http://www.google.com/search?client=safari&rls=en&q=php+form+update+database&ie=UTF-8&oe=UTF-8

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.