Ok,
this is what I have put together and it is fetching all the fields, could someone point me in the direction on how to write the information to the database:
I know this is wrong, but maybe you guys will understand a bit more what I am trying to do.
<?php
include '/var/www/web7/web/network/db/mysql.php';
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_db_query ("tenant", "select * from extension")
or die ("Query failed");
get column metadata
$i = 0;
while ($i < mysql_num_fields ($result)) {
$meta = mysql_fetch_field ($result);
if (!$meta) {
echo "No information available<BR>\n";
}
$test=$_POST[$meta->name];
echo " $test " ;
$rows=$meta->name;
$i++;
}
mysql_free_result ($result);
mysql_select_db($database);
$query = "INSERT INTO tenant ($rows) VALUES ($test)";
echo $test ;
echo "<BR>";
echo $rows ;
mysql_query($query) or die('Error, insert query failed');
?>
This code outputs all the information from the form but getting this error Error, insert query failed so its not building the mysql query correctly. The idea for this is so that people can add rows to the database and it will write the information to the database. I have the form working, this reads the rows and builds the form, just need away to write the information to the database.
Many Thanks