Re: [PHP] problem From: teo <email protected>
Date: 07/15/01

Hi zerosumzero!
On Sun, 15 Jul 1979, zerosumzero <email protected> wrote:

> I have a form with a bunch of text fields in it. The name of the fields is
> the rowid of items in my data base:
>
> <FORM METHOD="post" ACTION="edit.php3">
>
> <textarea name="23" class="field"></textarea>
> <textarea name="2" class="field"></textarea>
> <textarea name="15" class="field"></textarea>
>
> <input type="Submit" name="save" value="submit">
>
> <FORM>
>
> Now, I want to change all of the items in the DB where a rowid was submited.
>
> Is there an easy way to do this?

here's a hint:

 <FORM METHOD="post" ACTION="edit.php3">
 
 <textarea name="f[23]" class="field"></textarea>
 <textarea name="f[2]" class="field"></textarea>
 <textarea name="f[15]" class="field"></textarea>
 
 <input type="Submit" name="save" value="submit">
 
 <FORM>

$f = $HTTP_POST_VARS['f']; // if you have register globals off

foreach ($f as $rowid => $content) {
    $rowid = (int)$rowid;
    // add some sanity checks on $content here
    $qs = "UPDATE idunnowhat SET content='$content' WHERE rowid=$rowid";
    $db->query($qs); // provided that $db is an database connection object or
   something
}

dere u go

-- teodor

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>