I have a php page that lists the results of a search. I need the same page to be a form that the user can choose one of the rows of data listed to edit. Right now, due to my challenged newbee brain, I just have a form text box where the user would type in the key filed from the rows listed - but I'm sure there is a better way to simplify this for the user.
Is it possible to make the key fields in the listed rows hyperlinks that, if clicked on, would populate the key text box in the form for submission? Or is there a better approach to take?
Here is my code:
[code=php]
$db = mysql_connect(" localhost", "root", "yeahright" ); mysql_select_db ("etest",$db );
$result = mysql_query("SE LECT * FROM incidents WHERE rm_date = '1900-01-01' ORDER BY incident_id",$d b);
echo "<table><tr >";
echo "<td><b>Inciden t</b></td>";
echo "<td><b>&nb sp Facility</b></td>";
echo "<td><b>&nb sp Location</b></td>";
echo "<td><b>&nb sp Person</b></td>";
echo "<td><b>&nb sp Injury</b></td>";
echo "<td><b>&nb sp Severity</b></td>";
echo "<td><b>&nb sp Incident Date</b></td>";
while ($myrow = mysql_fetch_arr ay($result))
{
echo "<tr><td>".$myr ow["incident_i d"]."</td>";
echo "<td>  ".$myrow["fac_id"]."</td>";
echo "<td>  ".$myrow["room_descr "]."</td>";
echo "<td>  ".$myrow["person_typ e"]."</td>";
echo "<td>  ".$myrow["injury"]."</td>";
echo "<td>  ".$myrow["severity"]."</td>";
echo "<td>  ".$myrow["inc_date"]."</td></tr>";
}
echo "</tr></table>";
[/code]
and:
[code=html]
<FORM METHOD="POST" ACTION="edit_ir .php">
<h3>Enter the Incident ID for the Report You Need to Edit:</h3>
<table border="0" cellpadding="0" >
<tr>
<td><INPUT TYPE=TEXT NAME="incident_ id" VALUE="" SIZE=6 MAXLENGTH=6></td>
<td><INPUT TYPE=SUBMIT VALUE="Edit"></td>
<td><INPUT TYPE=RESET VALUE="Reset"></td>
</tr>
</table>
</FORM>
[/code]
I'd like to either have the $myrow["incident_i d"] be a hyperlink that would fill in the ><INPUT TYPE=TEXT NAME="incident_ id" ---- or ---- have the ><INPUT TYPE=TEXT NAME="incident_ id" be a Dropdown field with all of the $myrow["incident_i d"] fields in the options list.
TIA,
jej1216
Is it possible to make the key fields in the listed rows hyperlinks that, if clicked on, would populate the key text box in the form for submission? Or is there a better approach to take?
Here is my code:
[code=php]
$db = mysql_connect(" localhost", "root", "yeahright" ); mysql_select_db ("etest",$db );
$result = mysql_query("SE LECT * FROM incidents WHERE rm_date = '1900-01-01' ORDER BY incident_id",$d b);
echo "<table><tr >";
echo "<td><b>Inciden t</b></td>";
echo "<td><b>&nb sp Facility</b></td>";
echo "<td><b>&nb sp Location</b></td>";
echo "<td><b>&nb sp Person</b></td>";
echo "<td><b>&nb sp Injury</b></td>";
echo "<td><b>&nb sp Severity</b></td>";
echo "<td><b>&nb sp Incident Date</b></td>";
while ($myrow = mysql_fetch_arr ay($result))
{
echo "<tr><td>".$myr ow["incident_i d"]."</td>";
echo "<td>  ".$myrow["fac_id"]."</td>";
echo "<td>  ".$myrow["room_descr "]."</td>";
echo "<td>  ".$myrow["person_typ e"]."</td>";
echo "<td>  ".$myrow["injury"]."</td>";
echo "<td>  ".$myrow["severity"]."</td>";
echo "<td>  ".$myrow["inc_date"]."</td></tr>";
}
echo "</tr></table>";
[/code]
and:
[code=html]
<FORM METHOD="POST" ACTION="edit_ir .php">
<h3>Enter the Incident ID for the Report You Need to Edit:</h3>
<table border="0" cellpadding="0" >
<tr>
<td><INPUT TYPE=TEXT NAME="incident_ id" VALUE="" SIZE=6 MAXLENGTH=6></td>
<td><INPUT TYPE=SUBMIT VALUE="Edit"></td>
<td><INPUT TYPE=RESET VALUE="Reset"></td>
</tr>
</table>
</FORM>
[/code]
I'd like to either have the $myrow["incident_i d"] be a hyperlink that would fill in the ><INPUT TYPE=TEXT NAME="incident_ id" ---- or ---- have the ><INPUT TYPE=TEXT NAME="incident_ id" be a Dropdown field with all of the $myrow["incident_i d"] fields in the options list.
TIA,
jej1216
Comment