Jump to content

Function Not Populating Arrays (retrieving Records Despite Their Existance)


Greywacke

Recommended Posts

The MySQL table 4_servicesuppliers looks as follows:

bigint_ServiceID	bigint_SupplierID	bigint_RegionID===============================================================1			1			101			1			3

now the following function is supposed to return the data for the suppliers bound to the service, but it does not. i get no errors, it just doesn't go into the if ($result) { constraint and iterate through these records when 1 is passed as the service id attribute. below is the table 5_suppliers containing all the supplier information.

bigint_SupplierID	text_SupplierName	text_SupplierW3===========================================================================1			Test Supplier 1		http://www.greywacke.co.za/2			Test Supplier 3		http://www.google.co.za/3			Test Supplier 2		http://www.google.co.za/text_ContactFirstName	text_ContactSurname	text_ContactPosition===========================================================================Pierre			du Toit			Freelance Web DevelopmentKoos			Koekemoer		ForemanKoos			Koekemoer		Foremantext_ContactE-mail	bigint_ContactTel	bigint_CurrentBalance===========================================================================pierre@greywacke.co.za	27729154799		1000koos@gmail.com		27119756969		1000koos@gmail.com		27119756969		1000

below is the function that is supposed to iterate through these values, and add them to the top level arrays $mailadds and $supplierids. $regionids has been populated already with the selected region and childregions.

function getsuppliers($id) {	$sql1 = "SELECT * FROM 4_servicesuppliers WHERE bigint_ServiceID = ".$id.";\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 (in_array($row1["bigint_RegionID"],$GLOBALS["regionids"]) && !in_array($row1["bigint_SupplierID"],$GLOBALS["supplierids"])) {				$sql2 = "SELECT * FROM 5_suppliers WHERE bigint_SupplierID = ".$row1["bigint_SupplierID"]." AND bigint_bigint_CurrentBalance >= ".$servicecost.";\n";				$GLOBALS["sql"] .= $sql2;				$result2 = mysql_query($sql2);				$err = mysql_error();				$GLOBALS["sql"] .= strtoupper($err)."\n";				if ($result2) {					while ($row2 = mysql_fetch_array($result2)) {						array_push($GLOBALS["mailadds"], $row2["text_ContactFirstName"]." ".$row2["text_ContactSurname"].";".$row2["text_SupplierName"].";".$row2["text_ContactE-mail"].";".$row2["bigint_CurrentBalance"]);						array_push($GLOBALS["supplierids"], $row2["text_SupplierID"]);					}				}			}		}	}}

why would it not be iterating the records despite their being 2, and 1 distinct supplier?

Link to comment
Share on other sites

YAYfigured what was wrong :) see if you can, and i'll tell you :)got some other stuff to debug now though,laters :)

Link to comment
Share on other sites

okay got the entire code to work, choose recipients on available regions according to service and mail them the lead :)this topic can now be closed. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...