Re: add/edit combo form--opinions wanted
From: Andy Hassall (andy_at_andyh.co.uk)
Date: 07/12/04
- Next message: Andy Hassall: "Re: Passing values between scripts:"
- Previous message: Antoni: "Passing values between scripts:"
- In reply to: Xenophobe: "add/edit combo form--opinions wanted"
- Next in thread: Tony Marston: "Re: add/edit combo form--opinions wanted"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 12 Jul 2004 21:44:08 +0100
On Mon, 12 Jul 2004 20:29:43 GMT, "Xenophobe" <xenophobe@planetx.com> wrote:
>I would like to use the same form for adding new records and editing
>existing records. New form values are contained in $_POST. Database values
>are contained in an associated array. It seems to me that in order to use
>the same form for both tasks, I need to assign the form field values to page
>variables. The flow might look something like this:
>
>if $_POST
>
>$variable1 = $_POST['field1'];
>$variable2 = $_POST['field2'];
>
>else if $rows
>
>$variable1 = $row['field1'];
>$variable2 = $row['field2'];
>
>end if
>
>Can someone suggest a simplier way to do this?
Cut out the repeated $variables and just use one array, e.g.
if ($rows)
$vars = &$row;
else
$vars = &$_POST;
And then use $vars['field1'], $vars['field2'] in the form?
-- Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
- Next message: Andy Hassall: "Re: Passing values between scripts:"
- Previous message: Antoni: "Passing values between scripts:"
- In reply to: Xenophobe: "add/edit combo form--opinions wanted"
- Next in thread: Tony Marston: "Re: add/edit combo form--opinions wanted"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|