Jump to content

Someone!!! Code Help... ? Got any clues ??


ksgush

Recommended Posts

??? ??? ??? ??? ???

 

Hi, New Member Here... Was wondering if anyone had any clues on to how I could do this same thing but a hell of alot simpler.... Right now it doesn't return anything.. not even in view source.. But I contribute that to so many open connections, and someplace i know it probably broke..

 

The purpose of this little script is to take look at orders in a mssql db, than jump through the other db's to find the information it needs to find out if the Quantity on hand is more or equal to than the quantity the customer wants to order.

 

Here is the idea in another way.

find orders that are not shipped...

 

SELECT    *

FROM        WSTCompOrders

WHERE    (NOT (OrderStatus = '6')) AND (NOT (OrderStatus = '5')) AND (NOT (OrderStatus = '4'))

Take 'CartID' from above query for each order AND that will be used for OrderNumber below

 

 

SELECT    *

FROM        WSTCart

WHERE    (OrderNumber = 'CartID')

For each order number... take 'Quantity' and 'ProductID' which is what the customer wants

 

SELECT    *

FROM        Products

WHERE    (ID = 'ProductID')

 

and 'ProductID' it will give you the manufacturer part number which you will find in the RMSDB to find the quantity.

'ManPartNumbers'

 

 

 

RMSDB ON LOCAL

 

SELECT    *

FROM        Item

WHERE    (ItemLookupCode = 'ManPartNumbers')

 

 

 

 

 

NOW COMPARE the feild 'Quantity' to the field on WSTCART which is 'Quantity'

and if quantity is on rms db is greater than or equal to the quantity on WSTCART

then display to screen that says it should be shipped and we must have forgot

about it.

 

 

 

 

 

 

 

 

 

 

 

 


<?php	
	include("config.php");


	$connect1_dbhandle = mssql_connect($connect1_SERVER, $connect1_USER, $connect1_PASS)
		or die("Couldn't connect to SQL Server on $connect1_SERVER");
	$connect1_selected = mssql_select_db($connect1_DB, $connect1_dbhandle)
	or die("Couldn't open database $connect1_DB"); 
	$connect1_query = "SELECT CartID ";
	$connect1_query .= "FROM WSTCompOrders ";
	$connect1_query .= "WHERE (NOT (OrderStatus = '6')) AND (NOT (OrderStatus = '5')) AND (NOT (OrderStatus = '4'))";
	$connect1_result = mssql_query($connect1_query);
	while($connect1_row = mssql_fetch_array($connect1_result))
	{


				$part2_dbhandle = mssql_connect($connect1_SERVER, $connect1_USER, $connect1_PASS)
					or die("Couldn't connect to SQL Server on $connect1_SERVER");
				$part2_selected = mssql_select_db($connect1_DB, $part2_dbhandle)
				or die("Couldn't open database $connect1_DB"); 
				$part2_query = "SELECT Quantity, ProductID, OrderNumber ";
				$part2_query .= "FROM WSTCart ";
				$part2_query .= "WHERE OrderNumber = '" . $connect1_row["CartID"] . "'";
				$part2_result = mssql_query($part2_query);
				while($part2_row = mssql_fetch_array($part2_result))
					{


						$PRODUCTS_dbhandle = mssql_connect($connect1_SERVER, $connect1_USER, $connect1_PASS)
							or die("Couldn't connect to SQL Server on $connect1_SERVER");
						$PRODUCTS_selected = mssql_select_db($connect1_DB, $PRODUCTS_dbhandle)
						or die("Couldn't open database $connect1_DB"); 
						$PRODUCTS_query = "SELECT ManPartNumbers ";
						$PRODUCTS_query .= "FROM Products ";
						$PRODUCTS_query .= "WHERE ID = '" . $part2_row["ProductID"] . "'";
						$PRODUCTS_result = mssql_query($PRODUCTS_query);
						while($PRODUCTS_row = mssql_fetch_array($PRODUCTS_result))
							{
								$RMS_dbhandle = mssql_connect($connect2_SERVER, $connect2_USER, $connect2_PASS)
									or die("Couldn't connect to SQL Server on $connect2_SERVER");
								$RMS_selected = mssql_select_db($connect2_DB, $RMS_dbhandle)
								or die("Couldn't open database $connect2_DB"); 
								$RMS_query = "SELECT Quantity ";
								$RMS_query .= "FROM rmsBetaDB ";
								$RMS_query .= "WHERE ItemLookupCode = '" . $PRODUCTS_row["ManPartNumbers"] . "'";
								$RMS_result = mssql_query($RMS_query);
								while($RMS_row = mssql_fetch_array($RMS_result))
									{	
										if( $RMS_row["Quantity"] >= $part2_row["Quantity"]  )
										{
											echo $connect1_row["CartID"] . "should be shipped<br><br><br>";
										}
										else 
										{

										}											



									}




							}


					}

	}		


	?>

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.