473,626 Members | 3,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

add/edit combo form--opinions wanted

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?
Jul 17 '05 #1
5 2304
On Mon, 12 Jul 2004 20:29:43 GMT, "Xenophobe" <xe*******@plan etx.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 <an**@andyh.co. uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #2

"Xenophobe" <xe*******@plan etx.com> wrote in message
news:XwCIc.6269 9$MB3.53701@att bi_s04...
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?


The simple way is to not use the same form for both operations. If you use
separate scripts for input and amend you don't have to work out whether the
user's input is for a INSERT or an UPDATE. This is what the KISS principle
is all about.

--
Tony Marston

http://www.tonymarston.net

Jul 17 '05 #3
Xenophobe 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?


isset($_POST['field1']) ? variable1 = $_POST['field1'] : variable1 = '';

but

don't use same form for both operations. You can have 2 forms in single
script(file) each triggered by passed variable

FE:
index.php?actio n=edit || index.php?actio n=add

--
kreso
Jul 17 '05 #4
True, but the forms (there are several, depending on the category of
information being entered) is quite lengthy and--for ease of development &
maintenance--was hoping to use one form for each.

That said, I will probably go ahead and use separate forms for each
(add/edit) and hope the client isn't change order happy.

"Tony Marston" <to**@NOSPAM.de mon.co.uk> wrote in message
news:cd******** ***********@new s.demon.co.uk.. .

"Xenophobe" <xe*******@plan etx.com> wrote in message
news:XwCIc.6269 9$MB3.53701@att bi_s04...
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?


The simple way is to not use the same form for both operations. If you use
separate scripts for input and amend you don't have to work out whether

the user's input is for a INSERT or an UPDATE. This is what the KISS principle
is all about.

--
Tony Marston

http://www.tonymarston.net

Jul 17 '05 #5
> True, but the forms (there are several, depending on the category of
information being entered) is quite lengthy and--for ease of development &
maintenance--was hoping to use one form for each.
That said, I will probably go ahead and use separate forms for each
(add/edit) and hope the client isn't change order happy.


Always include the unchanging parts in order to ease development & big
fixes. Another thing is, that client should see what makes him happy. But he
is not propably interested in how you do it?

Make copy-paste scripts in internet are all-in-one-form type, but I ahve
also discovered that it makes things messy, when you have to speculate "if
elseif...." all the time.

Usually I have do my forms like this:
<form action="adfsdfa s">
<input type=hidden name=sender value=add_recor d>
......
<input type=submit name=sub value="ADD">
<input type=submit name=sub value="DO SOMETHING ELSE">
</form>

This way I have more freedom to name submit buttons the way I want, even I
can have same names in different forms, because sender (or it could be also
just the name of the form!) separates them. Of course I could speculate the
name of the submitbutton instead of its value, but it results more
dirtylooking code.
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
10991
by: Lucinda Roebuck | last post by:
I'm using Access 97 on a Windows XP computer. The combo box on the form "form1" will not refresh after a new name is added to the list. The "limit to list" properties for the combo box is set to yes. When I type a clients name in the box that is not in the list, the form "Add New Client Form" opens to add the client. When I return to the main form, the combo box will not refresh until I click on a name in the box and then click the...
1
1465
by: Jim Heavey | last post by:
Suppose you had a Data Grid which had 7 columns in the normal mode. but when you selected "edit" mode you wanted 6 columns to appear on line 1 and the 7th column to appear on Line 2 under column 6. Is there a way to do this with the DataGrid, or is the only way to do this is to used the DataList? Thanks in advance for your assistance!
6
3748
by: Ron L | last post by:
I have a dataset whose source is a SQL 2k stored procedure that I am trying to display in a datagrid. This datasource has 4 columns that I am interested in here, a text column and 3 value columns corresponding to permissions to certain data classes. I want to put the permission values in combo boxes in the grid and instead of displaying the numeric values, have the combo box display a string that corresponds to the numeric value (i.e. No...
9
6168
by: Duncan Barnes-Ceeney | last post by:
I’m having problems with a custom Combo box. The main problem is that I want to modify the look of the combo which includes the size of the button. To do this I have inherited from the standard combo set it as a UserPaint and provided my own paint. This along with the standard Owner Draw for the list items works fine for the DropDownList version, the problems start with the versions with the edit box which are where the problems are. ...
1
2461
by: The Eclectic Electric | last post by:
I'd be very grateful if anyone could help me with this. From my limited knowledge of Javascript I don't think it is possible, but I'll punt anyway. I downloaded and very slightly adapted this guy's Javascript "combo box" - http://sandy.mcarthur.org/javascript/select/select.html. It allows my users (when I get some!) to select from a list of preexisting options and also to add a new one by clicking on "add new". Essentially it's a select...
0
1886
by: Josetta | last post by:
This is for informational purposes...I had a problem and I thought it might help others in a similar situation. I hope someone, someday, finds this idea useful. I've garnered so much knowledge from this forum over the years, it's nice to present a solution that I couldn't find here. I have a form that my users wanted to filter, using the right-click Filter By or Filter Excluding, etc. I have a check box which my reports look up,...
1
2053
by: sejal17 | last post by:
hi everyone, I have a page with combo box. paypal payment:<select name="paypal"> <option value="On">On</Option> <option value="Off">Off</Option> </select> I want to edit the value.If i have add On then in editing i want to edit it with Off.
8
3456
ddtpmyra
by: ddtpmyra | last post by:
Hi, I have PHP script that I use for new entry and edit entry, inside the form I have query combo (combo values querying from other table), my problem is how make the default value of my combo to actual value on the edit table instead on picking the first value on my query. For instance I have query combo CAT, DOG, RABBIT. 1st time entry user choose RABBIT and then save, then user go back to edit page this time the combo will display...
0
30374
by: Gordon Padwick | last post by:
A form contains controls, one or more of which can be other forms. A form that contains another form is known as a main form. A form contained by a main form is known as a subform. A subform itself can contain other forms, sometimes known as subsubforms. This article deals only with main forms and their immediate subforms. The books about Access I’ve read contain some useful information about subforms, but don’t adequately cover the matter of...
0
8272
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8644
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6126
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4208
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2632
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1516
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.