473,320 Members | 1,900 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,320 software developers and data experts.

Comparing Data in two tables,

Hi, i was wondering if anyone would be able to help me with a problem
i'm having,

I currently have two tables, in a database, one is Called products, and
one is called groupproducts, their are multiple groups which can be
added to or removed from.

I want to creat a screen which lists all of the products and then
places a tick in a tick box if that products in the specified group.
From this i'd submit it to another page which update the group

products.

I'm currently doing the same system but having to edit it on a product
by product basis which is very time consuming!

Any suggestions would be appreciated.

Thanks

Ian

Jul 17 '05 #1
2 1546
On 17 Jun 2005 02:27:42 -0700, in comp.lang.php "Ian N"
<ia*******@gmail.com> wrote:
| Hi, i was wondering if anyone would be able to help me with a problem
| i'm having,
|
| I currently have two tables, in a database, one is Called products, and
| one is called groupproducts, their are multiple groups which can be
| added to or removed from.
|
| I want to creat a screen which lists all of the products and then
| places a tick in a tick box if that products in the specified group.
| >From this i'd submit it to another page which update the group
| products.
|
| I'm currently doing the same system but having to edit it on a product
| by product basis which is very time consuming!
|
| Any suggestions would be appreciated.


Updating multiple records from a single form is pretty easy (when you
know how) :-)

The trick is that you will need to associate the groupproducts
controls with each product. You can do this by:
<input name="prod<%php echp productid%>" value="<?php echo
productid%>|<%php echo groupdid%>" ...
This will result in the html code of:
<input name="prod101" value="101|1" ...
<input name="prod101" value="101|9" ...
<input name="prod101" value="101|5" ...
<input name="prod222" value="222|1" ...
<input name="prod222" value="222|9" ...
<input name="prod222" value="222|5" ...
When the form is submitted you will see this list of values which can
be exploded to separate the info.

The only problem here is that the names are dynamically generated so
you will not know, in advance, what to process. You will need to loop
through the $_GET or $_PUT item to extract this info.
The $_GET will look like:
&prod101=101|1&prod101=101|9&prod222=222|5&prod222 =222|9

(my php is pretty woeful so I wont even attempt at giving you so
sample code).
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Jul 17 '05 #2
Jeff North wrote:
The trick is that you will need to associate the groupproducts
controls with each product. You can do this by:
<input name="prod<%php echp productid%>" value="<?php echo
productid%>|<%php echo groupdid%>" ...
This will result in the html code of:
<input name="prod101" value="101|1" ...
<input name="prod101" value="101|9" ...
<input name="prod101" value="101|5" ...
<input name="prod222" value="222|1" ...
<input name="prod222" value="222|9" ...
<input name="prod222" value="222|5" ...
When the form is submitted you will see this list of values which can
be exploded to separate the info.


Unfortunately, if your code looks like this, then only the last input
with the same name will have anything in it.

What you should do is use arrays for your input name:
echo '<input name="prod[' .$productid. '][]" value="' . $productid .
'|' . $groupid .'">';

When you're writing/debugging the code, first make a dummy script
instead of the real processing script. In this dummy script, just put a
dump of the $_POST array:

<?php
echo '<pre>'; print_r ($_POST); echo '</pre>';
?>

This will show you what is being passed to your script. The you can
start actual coding.

Ken

Jul 17 '05 #3

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

Similar topics

41
by: Odd-R. | last post by:
I have to lists, A and B, that may, or may not be equal. If they are not identical, I want the output to be three new lists, X,Y and Z where X has all the elements that are in A, but not in B, and...
2
by: Bung | last post by:
Hi, I am not really familiar with MS ACCESS. However, I am trying to make some reports where you compare current data from a table with old data from the same table. What I'm saying is we have...
4
by: osmethod | last post by:
Hello, I have read many articles about comparing tables, like - loops, delete queries, appending to temp table with index etc Problem: 2 tables T1 & T2. Data is suppposed to be the same in...
0
by: laxmiuk | last post by:
I've original version of a table called PMM (Product Material Master). Thro' a web interface, user can change that table contents. Once changed, i need to raise an ECN (Engineering CHange Note)...
2
by: windandwaves | last post by:
Hi Guys I want to find out if two tables are identical (e.g. same fields, same indexes, etc....). Not the data, but the table structure itself. Is there a smart way to do that? Cheers
2
by: Shum | last post by:
Hi! i am working on a hospital data base. i have two tables Administration and knowlege base. in Administration i have columns ID, NumberOfDoctors etc, and in KnowlegeBase i have some similar...
8
by: irek.szczesniak | last post by:
Hi, I have table pairs that I need to compare, and produce another table that shows differences. I can't just open them in separate browser and look for differences, because I have many such...
5
by: Franck | last post by:
how come unchanged always true even if data changed This code come from my saving button: ============================================ DataSet ds1 = new DataSet(); DataSet ds2 = new...
4
by: gillianbrooks91 | last post by:
Forgive me for asking this question, I've trawled through nearly every available post on this subject that I can find for a few weeks now but nothing quite points me in the right direction. I'm...
11
by: jennifersalcido | last post by:
Hello All, I am working with two tables that contain inventory data: 1) INVENTORY contains item_number, description, etc. This data is relatively straight-forward, one record per item_number....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.