Direct Connect to MySQL using PHP
MySQL is a very popular open source database software.
You have a choice to retrieve the tax data aggregated for state-level reporting (Basic) or partitioned to local municipalities (Breakout).
Basic: Direct Connect to MySQL using PHP
<?php
$strServer = "db.Zip2Tax.com";
$strDBUsername = "z2t_link";
$strDBPassword = "H^2p6~r";
$strDatabase = "zip2tax";
//Open the connection
$conn = mysql_connect($strServer, $strDBUsername, $strDBPassword, 0, 65536)
or die("Failed to connect to MySQL server on $strServer");
//Open the Database
mysql_select_db($strDatabase, $conn)
or die("Could not open database $strDatabase");
//Set-up query variables
$strZipCode = "90210"; //sample zip code must be between 90001 and 92999
$strUserName = "sample";
$strUserPassword = "password";
//Execute
$result = mysql_query( "CALL zip2tax.z2t_lookup('" . $strZipCode . "','" . $strUserName . "', '" . $strUserPassword . "')" )
or die( mysql_error() );
//Read the result
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "Zip Code: " . $row['Zip_Code'] . "<br>";
echo "Sales Tax Rate: " . $row['Sales_Tax_Rate'] . "<br>";
echo "Post Office City: " . $row['Post_Office_City'] . "<br>";
echo "County: " . $row['County'] . "<br>";
echo "State: " . $row['State'] . "<br>";
echo "Shipping Taxable: " . $row['Shipping_Taxable'] . "<br>";
}
//Close the Database
mysql_close($conn);
?>
$strServer = "db.Zip2Tax.com";
$strDBUsername = "z2t_link";
$strDBPassword = "H^2p6~r";
$strDatabase = "zip2tax";
//Open the connection
$conn = mysql_connect($strServer, $strDBUsername, $strDBPassword, 0, 65536)
or die("Failed to connect to MySQL server on $strServer");
//Open the Database
mysql_select_db($strDatabase, $conn)
or die("Could not open database $strDatabase");
//Set-up query variables
$strZipCode = "90210"; //sample zip code must be between 90001 and 92999
$strUserName = "sample";
$strUserPassword = "password";
//Execute
$result = mysql_query( "CALL zip2tax.z2t_lookup('" . $strZipCode . "','" . $strUserName . "', '" . $strUserPassword . "')" )
or die( mysql_error() );
//Read the result
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "Zip Code: " . $row['Zip_Code'] . "<br>";
echo "Sales Tax Rate: " . $row['Sales_Tax_Rate'] . "<br>";
echo "Post Office City: " . $row['Post_Office_City'] . "<br>";
echo "County: " . $row['County'] . "<br>";
echo "State: " . $row['State'] . "<br>";
echo "Shipping Taxable: " . $row['Shipping_Taxable'] . "<br>";
}
//Close the Database
mysql_close($conn);
?>
Breakout: Direct Connect to MySQL using PHP
<?php
$strServer = "db.Zip2Tax.com";
$strDBUsername = "z2t_link";
$strDBPassword = "H^2p6~r";
$strDatabase = "zip2tax";
//Open the connection
$conn = mysql_connect($strServer, $strDBUsername, $strDBPassword, 0, 65536)
or die("Failed to connect to MySQL server on $strServer");
//Open the Database
mysql_select_db($strDatabase, $conn)
or die("Could not open database $strDatabase");
//Set-up query variables
$strZipCode = "90210"; //sample zip code must be between 90001 and 92999
$strUserName = "sample";
$strUserPassword = "password";
//Execute
$result = mysql_query( "CALL zip2tax.z2t_lookup_extended('" . $strZipCode . "','" . $strUserName . "', '" . $strUserPassword . "')" )
or die( mysql_error() );
//Read the result
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "Zip Code: " . $row['Zip_Code'] . "<br>";
echo "Sales Tax Rate: " . $row['Sales_Tax_Rate'] . "<br>";
echo "Post Office City: " . $row['Post_Office_City'] . "<br>";
echo "County: " . $row['County'] . "<br>";
echo "State: " . $row['State'] . "<br>";
echo "Shipping Taxable: " . $row['Shipping_Taxable'] . "<br>";
echo " Sales Tax Rate State: " . $row[' Sales_Tax_Rate_State '] . "<br>";
echo " Sales Tax Rate County: " . $row[' Sales_Tax_Rate_County '] . "<br>";
echo " Sales Tax Rate City: " . $row[' Sales_Tax_Rate_City '] . "<br>";
echo " Sales Tax Rate Special: " . $row[' Sales_Tax_Rate_Special '] . "<br>";
echo " Sales Tax Reporting Code Total: " . $row[' Sales_Tax_Reporting_Code_Total '] . "<br>";
echo " Sales Tax Reporting Code State: " . $row[' Sales_Tax_Reporting_Code_State '] . "<br>";
echo " Sales Tax Reporting Code County: " . $row[' Sales_Tax_Reporting_Code_County '] . "<br>";
echo " Sales Tax Reporting Code City: " . $row[' Sales_Tax_Reporting_Code_City '] . "<br>";
echo " Sales Tax Reporting Code Special: " . $row[' Sales_Tax_Reporting_Code_Special '] . "<br>";
}
//Close the Database
mysql_close($conn);
?>
$strServer = "db.Zip2Tax.com";
$strDBUsername = "z2t_link";
$strDBPassword = "H^2p6~r";
$strDatabase = "zip2tax";
//Open the connection
$conn = mysql_connect($strServer, $strDBUsername, $strDBPassword, 0, 65536)
or die("Failed to connect to MySQL server on $strServer");
//Open the Database
mysql_select_db($strDatabase, $conn)
or die("Could not open database $strDatabase");
//Set-up query variables
$strZipCode = "90210"; //sample zip code must be between 90001 and 92999
$strUserName = "sample";
$strUserPassword = "password";
//Execute
$result = mysql_query( "CALL zip2tax.z2t_lookup_extended('" . $strZipCode . "','" . $strUserName . "', '" . $strUserPassword . "')" )
or die( mysql_error() );
//Read the result
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "Zip Code: " . $row['Zip_Code'] . "<br>";
echo "Sales Tax Rate: " . $row['Sales_Tax_Rate'] . "<br>";
echo "Post Office City: " . $row['Post_Office_City'] . "<br>";
echo "County: " . $row['County'] . "<br>";
echo "State: " . $row['State'] . "<br>";
echo "Shipping Taxable: " . $row['Shipping_Taxable'] . "<br>";
echo " Sales Tax Rate State: " . $row[' Sales_Tax_Rate_State '] . "<br>";
echo " Sales Tax Rate County: " . $row[' Sales_Tax_Rate_County '] . "<br>";
echo " Sales Tax Rate City: " . $row[' Sales_Tax_Rate_City '] . "<br>";
echo " Sales Tax Rate Special: " . $row[' Sales_Tax_Rate_Special '] . "<br>";
echo " Sales Tax Reporting Code Total: " . $row[' Sales_Tax_Reporting_Code_Total '] . "<br>";
echo " Sales Tax Reporting Code State: " . $row[' Sales_Tax_Reporting_Code_State '] . "<br>";
echo " Sales Tax Reporting Code County: " . $row[' Sales_Tax_Reporting_Code_County '] . "<br>";
echo " Sales Tax Reporting Code City: " . $row[' Sales_Tax_Reporting_Code_City '] . "<br>";
echo " Sales Tax Reporting Code Special: " . $row[' Sales_Tax_Reporting_Code_Special '] . "<br>";
}
//Close the Database
mysql_close($conn);
?>