Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

need help putting a simple mysql query together


petercascio

Recommended Posts

Posted

I've modded our store so it sends out two different emails, one to the customer and a quite diferent one to the store owner. I've also added a tax by county contribution which I've modded for NY state.

 

Now I need to put some extra info into the email to the store owner but as a mysql newbie I got totally lost.

 

My variable $county_id comes from 'zone_id' in table 'zones'.

 

Using $county_id I need to get the tax reporting code 'nytax_code' and tax rate 'tax_rate' which are in table 'tax_rates' and stick them into the email.

 

I won't even post here what I put together on a test page because I'm sure I'd get laughed out of the room!

 

Peter

Posted

After phutzing around for quite some time I came up with the following kludge -- PLEASE, no laughing!

 

It works, but any suggestions on improving it?

 

// pull out the county from 'state' which is in the format "NY (My County)"

$my_variable_county = $order->billing['state'];
$query = "SELECT * FROM zones WHERE zone_name = '$my_variable_county'";
$answer = mysql_query($query);
$row = mysql_fetch_array( $answer );
$my_variable_zone=$row['zone_id'];   //extract the zone's ID from the answer


// now use zone_id to locate the state's four digit tax ID and the tax rate for this county

$query = "SELECT * FROM tax_rates WHERE tax_zone_id = '$my_variable_zone'";
$answer = mysql_query($query);
$row = mysql_fetch_array( $answer );
$my_variable_district=$row['tax_dist'];   //extract the state's four digit tax ID from the answer
$my_variable_rate=$row['tax_rate'];   //extract the tax rate for this county from the answer

Archived

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

×
×
  • Create New...