Forum Moderators: coopster
so far i have an add_data.php which autogenerates the fields according to the # and type of fields:
if ($fields) {
while($field=mysql_fetch_field($fields)) {
// fetch all the field types and display input text or textarea accordingly for each field
if (($field->type!="timestamp") &&
(strPos(mysql_field_flags($fields,$i),"auto_increment") == false))
{
$rows = "<tr>\n";
$rows .= "<td>$field->name</td>\n";
if ($field->numeric == true){
$rows .= "<td><input type=text id=$field->name name=$field->name></td>\n";
}
// then test for string and blob
... }
}
i would like to use a similar function to edit the db, by autogenerating the form using the mysql_fetch_field function but incorporating the values based on the ID variable passed in the url by using mysql_fetch_row
the end result would be edit_data.php which could be used as a generic form for updating all types of table.
obviously i need to get the ID
$ID=$_POST['id'];
// then get all the info out of database
while ($get_info = mysql_fetch_row($result)) {
// then i read out all the values
foreach ($get_info as $value) {
// then i can insert $value in each form tag..
e.g.
$rows = "<tr>\n";
$rows .= "<td>$field->name</td>\n";
if ($field->numeric == true){
$rows .= "<td><input type=text name=$field->name value=$value></td>\n";
i am just not sure how to insert the $value
many thanks!