Hello.
I have the following code which pulls an ID, country code, tax rate, state and name from a tbltax table, which uses 'while' to loop through the results. There are currently 3 sets of results, but there could be more or less.
$taxlist = array();
$taxesquery = "SELECT * FROM tbltax";
$taxesresult = mysql_query($taxesquery);
while ($myrow = mysql_fetch_array($taxesresult, MYSQL_ASSOC)) {
array_push($taxlist, $myrow["id"], $myrow["level"], $myrow["country"], $myrow["taxrate"], $myrow["state"], $myrow["name"]);
}
I get the following results for the $taxlist array (remember, these are just test values):
Array
(
[0] => 4
[1] => 1
[2] => ZA
[3] => 14.00
[4] =>
[5] => SA VAT
[6] => 3
[7] => 1
[8] => GB
[9] => 15.00
[10] =>
[11] => UK VAT
[12] => 5
[13] => 1
[14] => US
[15] => 20.00
[16] => Washington
[17] => US VAT
)
I can at least get each 'while' pushed to the end of the $taxlist array. However, I would like the $taxlist array to have a better structure so I can easily match against it based on things like the country or state.
If, for example, I want to see if a tax rate exists for US or GB, I need to be able to first see if it exists in the array (the US or G and if it does exist, find the rate for it.
Some tips / advice from a guru would be appreciated.