problem reading field names to form
Posted: Wed Mar 24, 2004 3:46 am
I need my script to print an input box from each field in database so that they are named by db:s fieldnames and valued by field's values.
started it this way:
<form action="" method="post" name="config_form">
</form>
OK. This prints as many input boxes as there are fields in DB, but...
i need it to name those inputs too.
I thought it would go somethin like this:
and then just echo it somehow inside prints of 1:st loop, but couldnt get it to work. I'd appreciate any kind of help...
Thanks.
started it this way:
Code: Select all
<?php
mysql_select_db($database_dbconn, $dbconn);
$query_config_read = "SELECT * FROM config";
$config_read = mysql_query($query_config_read, $dbconn) or die(mysql_error());
$row_config_read = mysql_fetch_assoc($config_read);
$totalRows_config_read = mysql_num_rows($config_read);
$fields = mysql_num_fields($config_read);
?>Code: Select all
<?php
for( $loop = 1; $loop <= $fields; $loop++ ) {
echo "<input type='text' name='' value=''>".$name."<br>";
}
?>OK. This prints as many input boxes as there are fields in DB, but...
i need it to name those inputs too.
I thought it would go somethin like this:
Code: Select all
<?php
for( $read = 1; $read <= $fields; $read++ ) {
$name = mysql_field_name($row_config_read, $read);
}
?>Thanks.