Jump to content

Unable To Ensure Attributes Are Linked To A Supplier.


Greywacke
 Share

Recommended Posts

at the moment, with the current attributes asked for being kept in the top level array $attribids, it should not have all the suppliers in the list as not all suppliers have all the attributes linked in the 9_supplierattributes table.

// check if the supplier has an attribute linkedfunction hasattrib($supplierid,$attribid) {	$sql = "SELECT * FROM 9_supplierattributes		WHERE bigint_SupplierID = ".$supplierid."		AND bigint_ServiceID = ".$GLOBALS["service"]."		AND bigint_AttributeID = ".$attribid."		AND bigint_RegionID = ".$GLOBALS["region"].";\n";	$GLOBALS["sql"] .= $sql;	$result = mysql_query($sql);	$err = mysql_error();	$GLOBALS["sql"] .= strtoupper($err)."\n";	if ($result) {		while ($row = mysql_fetch_array($result)) {			return true;		}	}	return false;}// make sure all attributes are linkedfunction hasattribs($supplierid) {	$ret = true;	foreach ($GLOBALS["attribids"] as $attribid) {		if (!hasattrib($supplierid,$attribid)) {			$ret = false;			break;		}	}	return ret;}// checking wether has regions, and attributes and hasn't been added already before// adding, but adds to arrays despite that// $GLOBALS is to reference the top level variables on the page.function getsuppliers($svcid) {	$sql1 = "SELECT * FROM 4_servicesuppliers JOIN (5_suppliers) ON		(4_servicesuppliers.bigint_SupplierID = 5_suppliers.bigint_SupplierID)		WHERE bigint_ServiceID = ".$svcid.";\n";	$GLOBALS["sql"] .= $sql1;	$result1 = mysql_query($sql1);	$err = mysql_error();	$GLOBALS["sql"] .= strtoupper($err)."\n";	if ($result1) {		while ($row1 = mysql_fetch_array($result1)) {			if (inregion($row1["bigint_SupplierID"]) &&			  hasattribs($row1["bigint_SupplierID"]) &&			  !in_array($row1["bigint_SupplierID"],$GLOBALS["supplierids"])) {				array_push($GLOBALS["mailadds"], $row1["text_ContactFirstName"].				  " ".$row1["text_ContactSurname"].";".$row1["text_SupplierName"].				  ";".$row1["text_ContactE-mail"].";".				  $row1["bigint_CurrentBalance"]);				array_push($GLOBALS["supplierids"], $row1["bigint_SupplierID"]);			}		}	}}

but despite this, all suppliers for the service get added to the array. i believe i need a bit of help here please... i'll respond with anything that might be required.

Edited by Pierre 'Greywacke' du Toit
Link to comment
Share on other sites

please help someone, i cannot see why it would not be filtering the suppliers with nonexistant attributes...

Link to comment
Share on other sites

problem was fixed thanks.some coding had to be rewritten, the hasattribs and hasattrib functions dropped, and the problem disappeared with that. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...