Working with HTML, PHP, MySQL, Apache. I have successfully written an HTML form that submits data to a PHP page which inserts the data to a MYSQL Database. I also have a search HTML that hits another PHP page that displays the results of the search from the database.
I want the data displayed (there may be multiple rows) to be editable on a row-by-row basis. How do I pass the array values from the PHP into an HTML Form section on the PHP page so the existing data from the db is defaulted into the form field which the user can then change? Example: How do I get $myrow["fac_id"] from the PHP into a Form Field called "fac_id"?
This is my PHP section which correctly displays the results of the search:
[code]
<?php
$db = mysql_connect("localhost",
"root", "yeahright"); mysql_select_db("mytest",$
db);
$result = mysql_query("SELECT * FROM incidents WHERE incident_id = '$_REQUEST[incident_id]'",
$db);
echo "<table><tr>";
echo "<td><b>Incident</b></td>"
;
echo "<td><b>  Facility</b></td>";
echo "<td><b>  Location</b></td>";
echo "<td><b>  Other</b></td>";
echo "<td><b>  Person</b></td>";
echo "<td><b>  Name</b></td>";
echo "<td><b>  Street</b></td>";
echo "<td><b>  City</b></td>";
echo "<td><b>  State</b></td>";
echo "<td><b>  Zip</b></td>";
echo "<td><b>  Phone</b></td>";
echo "<td><b>  Birthdate</b></td></tr>";
while ($myrow = mysql_fetch_array($result)
)
{
echo "<tr><td>".$myrow["inciden
t_id"]."</
td>";
echo "<td>   ".$myrow["fac_id"]."</td>"
;
echo "<td>  ".$myrow["room_descr"]."</
td>";
echo "<td> ".$myrow["oth_d
escr"]."</
td>";
echo "<td>  ".$myrow["person_type"]."<
/td>";
echo "<td> ".$myrow["perso
n_name"]."
</td>";
echo "<td> ".$myrow["perso
n_street"]
."</td>";
echo "<td> ".$myrow["perso
n_city"]."
</td>";
echo "<td> ".$myrow["perso
n_state"].
"</td>";
echo "<td> ".$myrow["perso
n_zip"]."<
/td>";
echo "<td> ".$myrow["perso
n_phone"].
"</td>";
echo "<td> ".$myrow["dob"]
."</td></t
r>";
}
echo "</tr></table>";
$edit_fac_id=$myrow["fac_i
d"];
mysql_close($db);
?>
[/code]
After the PHP, my code is (doesn't work - fields are blank - I tried passing the array variables three diffferent ways):
[code]
<FORM NAME = "rm_edit_ir" METHOD="POST" ACTION="ir_updated.php">
<table border="0" cellpadding="0">
<tr><td>Facility:<br><INPU
T TYPE=TEXT NAME="fac_id" DEFAULT=$edit_fac_id SIZE=12 MAXLENGTH=12></td>
<td>Location:<br><INPUT TYPE=TEXT NAME="room_descr" DEFAULT=$myrow["room_descr
"] SIZE=32 MAXLENGTH=25></td>
<td>Other:<br><INPUT TYPE=TEXT NAME="oth_descr" DEFAULT=$myrow["oth_descr"
] SIZE=32 MAXLENGTH=25></td>
</tr>
</table></FORM>
[/code]
TIA,
jej1216