On Thu, 2003-07-17 at 14:38, Mike Morton wrote: > Perhaps I was not that clear on the subject :) > > I have the following array: > > $SAVEVARS[headerimage]=$_POST[headerimage]; > $SAVEVARS[backgroundimage]=$_POST[backgroundimage]; > > I want to iterate through it to save to a database config: > > Forach($SAVEVARS as $whatever) { > $query="update table set $whatever=$whatever[$whatever]"; > } > > Where the 'set $whatever' would become 'set headerimage' and > '=$whatever[$whatever]' would become the value that was posted through and > set on the line above. > > The question is the - the assigned string key - is there a way to retrieve > that in a loop? Foreach, for, while or otherwise? > > -- > Cheers > > Mike Morton
foreach ($SAVEVARS as $key => $value) { $query = "update table set $key = '$value'"; } Also, unless you have constants named 'headerimage' and 'backgroundimage', you should quote the array subscripts: $SAVEVARS['headerimage'] = $_POST['headerimage']; etc. See the manual for why: http://www.php.net/manual/en/language.types.array.php#language.types.array.donts Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]> +1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====----- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php