[thelist] Looping through an updte query in php

Andrew Forsberg andrew at thepander.co.nz
Tue Jan 22 16:06:46 CST 2002


Hi John

>I need to write a script that will write each of the input field's contents
>to the DB. Obviously, I don't want to hard code the SQL to reflect each row
>(what happens when I add a property?) But I don't know how to get all the
>form inputs as an array and loop through them, constructing the proper SQL
>as I go <though I did just give myself a little hint...it will use an array
>loop>

How about using an $HTTP_POST_VARS["input"] array? So, your four text 
inputs could look like this in your html:

<input name="input[field1]" value="<?php echo 
$HTTP_POST_VARS["input"]["field1"];?>" />
<input name="input[field2]" value="<?php echo 
$HTTP_POST_VARS["input"]["field2"];?>" />
<input name="input[field3]" value="<?php echo 
$HTTP_POST_VARS["input"]["field3"];?>" />
<input name="input[field4]" value="<?php echo 
$HTTP_POST_VARS["input"]["field4"];?>" />

And your php code could step through the $HTTP_POST_VARS["input"] 
array in a while loop, creating the SQL update string as it goes.

>Forgot an FTP password but have the password stored in a WS_FTP.ini file?
>This handy URL has a script which translates a WS_FTP password from it's
>encoded form back to text.

Re: the password decoder, that sounds damned scary from a security POV! :)

Cheers
Andrew

-- 
Andrew Forsberg
---
uberNET - http://uber.net.nz/
the pander - http://thepander.co.nz/




More information about the thelist mailing list