Re: add/edit combo form--opinions wanted

From: Andy Hassall (andy_at_andyh.co.uk)
Date: 07/12/04


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


Relevant Pages

  • Re: KirbyBase
    ... creating objects from the database records was much easier. ... Hal, I don't know if you have had a chance to take a look at the beta yet, but I basically tried to implement a uniform way to specify one-to-one links, one-to-many links, and calculated fields in the ... I suppose it would in effect be embedding an array where all the ... My first couple of attempts at adding more complexity to KirbyBase did not honor this concept. ...
    (comp.lang.ruby)
  • Re: KirbyBase
    ... I'm an Object Guy and Jamey is a Database Guy. ... That requires the table name and key field name to be specified ... I suppose it would in effect be embedding an array where all the ... that is) might compress by a factor of 10 or more. ...
    (comp.lang.ruby)
  • Re: using BLOB objects and ...
    ... while saving the array object to the database which is ok but while ... convert it back to object of 4 dimention boolean array which will be ... will let you store your 4 dimensional boolean array in it. ... You may have to modify my suggestion ...
    (comp.lang.java.programmer)
  • Re: using BLOB objects and ...
    ... - You could use Memo if you converted your boolean array into a text string. ... boolean array when you fetch it from the database. ... You might be able to put the whole array in an OLE Object, ...
    (comp.lang.java.programmer)
  • Re: Permutations - 8 columns
    ... Thanks Markos for your input. ... SQL driver to access the database, I will have to use the long way to ... > Dim TotalAccounts As Long, ... We declare and resize an array variable with the ...
    (microsoft.public.excel.programming)