sorry, for explaining it baldy.
the link you send is not bad, but i wonder if i’d manage to change it to work like i want.
LOOK, THIS IS THE DOCUMENT, WHERE I, IN THE BEGINNING, BUILD AN ARRAY WITH THE FIELDS AND VALUES OF THE CURRENT TABLE
(there are docens of tables, so i want to minimize the amout the work to write down all the fields and values all the time):
$db = array(‘spendenzaehler’ => $_POST[‘spendenzaehler’],
‘spendenverwendung’ => $_POST[‘spendenverwendung’]);
// case 1 - the user submitted a new record for insertion
if (($_POST[‘submitted’]) && (!$_GET[‘update_record’])) {
insertRecord($db);
}
// case 2 - the user submitted an existing records ID to fill the form with the values to be edited
elseif ((!$_POST[‘submitted’]) && ($_GET[‘update_record’])) {
getRecord($db);
}
// case 3 - the user submitted an already existing record for actualisation
elseif (($_POST[‘submitted’]) && ($_GET[‘update_record’])) {
updateRecord($db);
}
AND HERE, THE FUNCTIONS:
function insertRecord($db) {
foreach($db as $field => $value) {
$fields .= $field.",";
$values .= “’”.$value."’,";
}
$fields = substr($fields,0,strlen($fields)-1);
$values = substr($values,0,strlen($values)-1);
$sql = "INSERT INTO $GLOBALS[table] ($fields) VALUES ($values)";
$success = mysql_query($sql, $GLOBALS[connectionID]);
}
function updateRecord($db) {
$sql = "UPDATE $GLOBALS[table] SET ";
foreach($db as $field => $value) {
$sql .= "$field = '$value',";
}
$sql = substr($sql,0,strlen($sql)-1);
$sql .= " WHERE id = '$GLOBALS[id]' ";
$success = mysql_query($sql, $GLOBALS[connectionID]);
}
function getRecord($db) {
$sql = “SELECT * FROM $GLOBALS[table] WHERE id = $GLOBALS[id]”;
$result = mysql_query($sql, $GLOBALS[connectionID])
or die ("Auswahl aus der Datenbank nicht m?glich.");
// THIS IS, HOW IT IS NORMALLY DONE
$spendenzaehler = mysql_result($result, 0, "spendenzaehler");
$spendenverwendung = mysql_result($result, 0, "spendenverwendung");
// AND THIS IS, HOW I - SOMEHOW - LIKE TO HAVE IT.
foreach($db as $field => $value) {
$sql = '$result, 0, "'.$field.'"';
$value = mysql_result($sql);
}
}
thank you very very much, cheers andre