473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Passing Data To Multi Use Form

I am working on a site where I need to create forms to both add and edit
information for a group of products. I would like to use the same form for
both adding new and edit data for existing products, while at the same time
separating data and presentation functions. So when the user selects the
option to add a new product, the form comes up with all drop down lists
filled from the database with the options for that field and all other
fields blank, and when a product is selected to be edited, I would like the
same form to come up, but this time with all the fields filled in, including
all drop down lists filled with the appropriate value for that product.

In the past, I've done something like this to fill drop down lists with the
valid options:

function add_product_form()
{
?>
<div name="add_new_product" align="center">
<h3>Add New Product</h3>
<form name="add_product" method="get" action="add_product.php">
<select name="category">
<?php
if (db_connect()) //sets up conenction to database
{
$query = "select * from category";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result))
{
$id = $row['category_sku'];
$name = $row['category_name'];
?>
<option value=<?php echo $id ?>><?php echo $name ?></option>
<?php
}
}
else
{
echo("Error connecting to host");
}
}

This snippet just shows one drop down list being created and filled with the
options. So how can I create a form to use for both adding new and editing
existing products, and only fill in the data if it is editing? If there is
an OO way to do this, that would be great. One idea I have is to pass a
variable that is set to either "new" or edit", and do something based on
that, but what I'm unsure about is how to pass the edited data to the form
from the function that gets it from the database.

Thanks.

Steve
Jul 17 '05 #1
0 1309

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

Similar topics

6
by: Hamed | last post by:
Hello I have employed as a developer in a software company that its team uses FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to migrate to VS.NET. There is a project...
2
by: Curtis Justus | last post by:
Hi, I currently have a control that is on a form and I want to pass that exact instance of the control to another form (a child form that appears on a button click). The control has state,...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
3
by: SQLScott | last post by:
I have looked all over and I cannot find an example or information on passing a multi-dimensional array. Well, that is not true. I found a close example in C++ but it didn't work when I...
10
by: Mark Denardo | last post by:
Hi, I have multi-threaded application that requires one particular thread (Non-Form based) to receive data from other threads. I know how to pass control to Form Threads, but I believe there's no...
4
by: entitledX | last post by:
Hi, I'm trying to use the HDF library to read a few HDF files that I need to process. The data in each file varies in rows, but the columns remain constant. Because of that, I had dynamically...
6
by: jej1216 | last post by:
I am trying to put together a PHP search page in which the user can select none, one, two, or three fields to search, and then the results php will build the SQL with dynamic where caluses to reflect...
4
by: John | last post by:
Hello All, Can someone help me with a problem I am having? I have a form which has a multi-select list where the user can select more than one company name from a list and I need to pass those...
4
by: Tom | last post by:
Hello all, Is there a method to fill out a web form and click the submit button in vb.net? I'm attempting to programmtically submit raw GPS data to http://www.ngs.noaa.gov/OPUS/ for...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.