Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass data from one table field to another

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB
Hi

Firstly, apologies if this is the wrong forum so if this is the case, please can you advise.

I have set up a website using oscommerce and all is working perfectly. One of the tables is called products and a field within that is called WEIGHT. This particular field is a VARCHAR(15) and at present is populated by a UPC/SKU number via uploading CSV files via phpmyadmin to reflect on titles on the website.

There is also another table called orders_products[b/]. I have looked at this table which is quite limited in the amount of fields it has so I added one called WEIGHT being the same as the field in the products table.

The reason for this question is, when we check our orders the UPC/SKU number will be shown on the customers order, we just copy and paste this into a Visual FoxPro app we have and this in turn creates an order to the supplier. We have been using barcode scanners to speed up the process with our procedures, hence the effort to do the same with this one.

Explanation out of the way....

Can someone please advise how to get the information from the products field WEIGHT and into the orders_products table at the time of ordering? I have posted this same question on the oscommerce forum but without reply.

I have managed to create, amend and do some updates to our site purely by research but will admit that I'm not an expert in php (but willing to give it a go).

If someone could just direct or advise me I would be grateful

Many thanks

Lee

Windows XP
Visual FoxPro Version 6 & 9
 
Not exactly a PHP question, more like a DB query question. but I'll give it a shot, if i understand you correctly:

You would have to execute a query on the products table at the moment of ordering to get the weight for the product, something like:

SELECT WEIGHT FROM products where productID='[red]$productid[/red]';


where [red]$productid[/red] would be the Id from the product whose weight you want, and which you would have gotten from a previous query, when setting up the orders.


Then just use that information to construct an INSERT query for the orders_products.

INSERT INTO orders_products ..., WEIGHT ... values(...,$weightfromselectquery,...);

Obviously this is all generic DB querying and really has very litle to do with PHP, if only to execute the queries at the appropriate time.




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
It should be quire straightforward

1) You need to find how is populated the first weight field
If so figure where and how the query to that weight field is performed
From there add another query to the new field table that will populate it.
2) OR: Look if weight is somehow passed as a session something in the range of:
$weight=$_SESSION[‘weight’];
If not create a session
$_session[‘weight’]=$weight;
$weight=$_SESSION[‘weight’];
Now you have a session called $weight
Go to your page where you want to use that data
Add to top of the page (if not there) session_start();
Then you are ready to use the weight value for any usage

I did not for years look at oscomm
But you will need to do your home work
For it certainly carries a bunch of templates , css etc…
Mostly it certainly is OOP
So the query might not look familiar to you

I am sure that the oscomm forum could let you know how that query is done

Good luck
 
Vacunita & webdev007

Thankyou for your posts and advice.

If I understand it correctly, webdev007 is pointing me in the direction (I think!) in that the section you mention:
2) OR: Look if weight is somehow passed as a session something in the range of:
$weight=$_SESSION[‘weight’];
If not create a session
$_session[‘weight’]=$weight;
$weight=$_SESSION[‘weight’];
is probably what I'm looking for.

You are right about oscommerce, I have found through much blood, sweat and tears that there are several files that need changing to perform a simple task.

Thanks again guys and when I find the php file(s) concerned I'll post back (don't hold your breath though!)

Lee

Windows XP
Visual FoxPro Version 6 & 9
 
keepingbusy, I hope that you have a good editor
in such case I open a whole dir content at a time ans perform a search with my editor
keep the search terms in the required field but go easy on degree of recognition.
Good Luck :)
 
Hi

Just a courtesy update on this thread.

After changing many php files (I think we discussed this would be the case), I eventually achieved what were looking for in an sql statement within one of the php files.

I inserted what's in bold below and it now works perfectly transfering the contents of the products table field (weight) to the orders_products table (weight). Not sure the reason behind this as well, but the field (weight) was previously a NULL. This was changed to NOT NULL and together with the sollution, it works.

As I mentioned, I'm not expert in php etc, but thanks again for the inspiration guys.

Here's that addition:
Code:
$index = 0;
$orders_products_query = tep_db_query("select orders_products_id, products_name, products_model, [b]products_weight[/b], products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");

Lee


Windows XP
Visual FoxPro Version 6 & 9
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top