Editing table entries

admin

Administrator
Staff member
I might be making this more complicated than it should be. Basically, I want to show
all contents of a mysql table on a web page, formatted neatly into an HTML table. I
can do that OK.

Then, I want to have radio buttons next to each record. A record can then be selected,
submitted, and then have the ability to edit that record, and re-insert it back into
the database.

What I have below does this up to the point where the record is submitted. I'm not
sure if it's possible to send that record into a form where the record data can be
edited and re-submitted.

Here's my code:

<?php
print "\n<head>\n\t<title>MySQL Table</title>\n</head>\n";
print "<body>\n";

mysql_connect( 'localhost', 'username', 'password' ) or die ( 'Unable to connect.' );
mysql_select_db( 'dbname' ) or die ( 'Unable to select database.' );

$sql = "SELECT * FROM test";
$result = mysql_query( $sql ) or die ( 'Unable to execute query.' );

print "<table border=1 width=400>
<tr>
<td width=200><B>Name</B></td>
<td width=200><B>Description</B></td>
</tr>
</table>\n";



print "<table border=1 width=400>\n";
while($row = mysql_fetch_array($result))
print "
<form method=get>
<tr>
<td width=200>
<input name='selection' TYPE='Radio' Value='http://www.phpbuilder.com/board/archive/index.php/$row[0]'>
$row[0]</td>

<td width=200>
<input name='selection' TYPE='Radio' Value='http://www.phpbuilder.com/board/archive/index.php/$row[1]'>
$row[1]</td>
</tr>\n";

print "</table>\n";

print "<input type=submit>\n";

print "</form>\n";

print "</body>\n\n";
?>

*******

Again, what I have here displays each HTML table cell with a radio button. I want to
have the option to select that cell data, and press the submit button, then send it to
a form for editing, and a resubmittal.

thanks...
 
Back
Top