Sure. (reply to original message)
From my function library, here is my first function to find the Model of the part number:
function getModel($part) {
$root = substr($part,0,4);
$query = "SELECT Root, Model FROM tbl_Root
WHERE Root = '$root'";
$result = mysql_query($query) or die ("Query Root failed: " . mysql_error());
while ($rec = mysql_fetch_array($result, MYSQL_ASSOC)) {
if (in_array($root, $rec)):
$Model = $rec['Model'];
else:
$Model = 'UNKNOWN';
endif;
}
return $Model;
}
When trying to find the attributes of several hundred part numbers, I pass them to a MySQL temp table that would then select the distinct part numbers and loop them through my functions.
$query = "SELECT DISTINCT A FROM TempAttributes";
$result = mysql_query($query) or die ("Query failed: " . mysql_error());
while ($rec = mysql_fetch_array($result, MYSQL_ASSOC)) {
$part = mysql_escape_string($rec['A']);
$Model = getModel($part);
$query = "REPLACE INTO tbl_Attributes
(Part, Model)
VALUES
('$part', '$Model')";
$endresult = mysql_query($query) or die ("Query Load failed: " . mysql_error());
}
Obviously this while loop is what doesnt work because the function return value when finding the Model exits the loop. Ultimately, my function library finds several other attributes, but I am trying to get this to work with just the Model for now. I know there must be some way of doing this!
Thanks for the input.