Thanks for the tip, but I'm not sure how I could apply it to my problem. The form that sends the data is constructed like this:
$Database = file('server_path_to_textfile');
echo '<p>Type in new values:</p>';
echo '<form id="writeitemsform" name="writeitemsform" action="processitems.php" method="post">';
foreach($Database as $row)
{
$line = explode('|', $row);
if ($line[0] !== '')
$SKU = ($line[0]);
$Description = ($line[1]);
$Price = ($line[2]);
$Status = ($line[3]);
echo '<p>Item ID: '.$SKU.'</p>';
echo '<p>Item Description: <input type="text" name="'.$SKU.'descriptionfield" value="'.$Description.'"></p>';
echo '<p>Item Price: <input type="text" name="'.$SKU.'pricefield" size="6" value="'.$Price.'">';
echo '<p>Status: ';
if ($Status == 'OK')
{
echo 'Available <input type="checkbox" name="'.$SKU.'status" value="OK" checked></p>';
}
elseif ($Status == 'NO')
{
echo 'Available <input type="checkbox" name="'.$SKU.'status" value="OK"></p>';
}
echo '<img src="../images/skuimages/'.$SKU.'.jpg" border="0" width="100" />';
}
echo '<p><input type="submit" name="submitnewfieldsbutton" id="submitnewfieldsbutton" value="Submit New Values"></p></form>';
Then it's the "processitems.php" that the form sends to, that I'm trying to write. The idea is to overwrite the database with the new values entered in the form. Like I said I'm kind of stuck here:
$sku1Descrip = $_POST['sku1descriptionfield'];
$sku1Price = $_POST['sku1pricefield'];
$sku1Status = $_POST['sku1status'];
..etc. I'm able to write it this way, enumerating each variable/field pair in a long list, because I can predict the database. But obviously I'd prefer to assign these variables in a loop, without such explicit reference to my knowledge about the database.
Maybe I'm using the wrong approach, but I feel some loop would work?