473,569 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1556
On 17 Jun 2005 02:27:42 -0700, in comp.lang.php "Ian N"
<ia*******@gmai l.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%>|<%p hp 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&p rod222=222|5&pr od222=222|9

(my php is pretty woeful so I wont even attempt at giving you so
sample code).
---------------------------------------------------------------
jn******@yourpa ntsyahoo.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%>|<%p hp 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
3916
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 Y contains all the elements that are B but not in A. Z will then have the elements that are in both A and B. One way of doing this is of course...
2
4193
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 a database with current data, and the same database with old data. I need to create reports for new rows inserted, deleted rows, and updates...
4
4147
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 both tables but i need to check that this is so. (Maybe a user deleted a row in one table only or changed a value in a field!). The tables have no...
0
1677
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) specifying what changes happened to original PMM table whether rows are deleted, new rows are added or existing rows are modified etc. I've both old...
2
1705
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
1349
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 columns but ofcourse differnet data. Administration ID Date HospitalName NumberOfDoctors ............................
8
2244
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 table pairs, and so this process has to be automated. Tables can differ in a number of ways - columns and rows can be added or missing, values of...
5
1843
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 DataSet(); DataSet ds3 = new DataSet(); //Static Dataset which contain values when my form load
4
6388
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 quite new to trying to mess around with VB and ADO within MS Access and have realised the steep learning curve I have, but, I want to try and solve...
11
10979
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. 2) INV_CROSS_REF contains item_number, and a data column containing either a scancode or a manufacturer part number. The type column indicates...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
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...
0
3653
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...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
938
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...

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.