
moldinaga
Posts: 4
|
| Posted: 11/18/2004, 1:15 PM |
|
Hello everyone.
I have three tables:
products
categories
products_to_categories
let's say products primary key is PID, categories is CID.
And products_to_categories contains only two fields: PID and CID, in other words it joins the first two tables in a many to many relationship. (some products can be in multiple categories)
Anyhoo, I'm a relative newbie at codecharge. Here's my problem: I used the record builder to make a page called add_category_to_prod, and the purpose of it is JUST to add one row to the products_to_categories table.
I don't want to delete, or update. Just add.
Well, let's say the link to this page looks like
add_category_to_prod.php?PID=5
What I want is for the PID to get passed in as one field, and then the user selects the category. Then upon submitting the form, a new record containing the passed in PID and the user-selected CID is added to the products_to_categories table.
BUT
what happens is that when I pass in the PID, the record form automatically thinks I want to edit an existing row in the table, and tries to populate the fields.
So what I want is a record builder form that I can pass parameters to, but those params will be used to populate some of the fields instead of to look up existing records.
Any suggestions?
thanks
|
 |
 |
peterr
Posts: 5971
|
| Posted: 11/18/2004, 4:05 PM |
|
Looks like the record form finds an existing records based only on the PID, which probably means that:
a) your database table is defined with just one key field, instead of both PID and CID
and/or
b) your table "products_to_categories" allows null values in CID
and/or
c) such record already exists in the database and can be retrieved based only on PID, even if CID is empty.
Try running this SQL directly in your database and see if any records are being returned:
"SELECT * FROM products_to_categories WHERE PID=5"
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
moldinaga
Posts: 4
|
| Posted: 11/18/2004, 7:56 PM |
|
Hi Peter; thanks for replying to me.
The table I am trying to add a record to, "products_to_categories", has only two columns, PID and CID and they are both primary keys in the table. So running the select statement above may return a few rows, like
PID CID
5 10
5 12
5 19
just indicating that this product (5) is a member of three categories.
My desire is not to update any records in this table, nor to retrieve any record in this table. What I want to do is use the record builder to add a record to this table.
Now, I know that I can make a form where the user enters a PID, and then enters a CID (however that is interfaced) and then these values are added.
But what I want is a form that has the PID value already filled in (it is passed to the form via URL). And the user only selects the category. Then hits "Add" and a new record (PID, CID) is added to the table.
Is this simple to do? I have spent much time on it. CCS is great, but the learning curve is daunting.
thanks
|
 |
 |
peterr
Posts: 5971
|
| Posted: 11/18/2004, 8:02 PM |
|
OK, then I think that in the Data Source of your Record form you only have specified the PID parameter, but also need CID. For example instead of selecting record with "Where PID = {PID}" you would need something like "Where PID = {PID} AND CID={CID}". So please open your Data Source property and review the parameters there.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
|

|
|
|
|