Comparing Data in two tables,

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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.
Quoted text here. Click to load it

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.



Re: Comparing Data in two tables,

On 17 Jun 2005 02:27:42 -0700, in comp.lang.php "Ian N"

Quoted text here. Click to load it

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:

(my php is pretty woeful so I wont even attempt at giving you so
sample code).
---------------------------------------------------------------  : Remove your pants to reply

Re: Comparing Data in two tables,

Jeff North wrote:
Quoted text here. Click to load it

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:

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

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


Site Timeline