I have been racking my brains trying to get something that seems simple to work. I have a TABLE "weight". Weight has 3 columns "shipping_to", "shipping_from", and "shipping_cost".
Shipping_to and Shipping_from are the weight values and shipping cost holds the shipping cost if the value is greater than or equal to X AND less than or equal to X.
I have written this a million different ways and for the life of me it won't work.
UPDATED: The Script works "kind of" but it never returns a success response of 1 and it never fimds the value of X even though I have manually put these values into my MySQL db.
PHP SCRIPT:
if($The_Function=="SHIPPING_COST"){
$response = array();
require_once __DIR__ . '/db_connect.php';
$con = new DB_CONNECT();
$ship_weight = 1;
$result = mysql_query("SELECT * FROM weight WHERE from_weight >= '$ship_weight' AND to_weight <= '$ship_weight'");
if(!empty($result)){
if (mysql_num_rows($result) > 0) {
$response["userID"] = array();
while ($row = mysql_fetch_array($result)) {
$custID = array();
$custID["shipping_cost"] = $row["shipping_cost"];
array_push($response["userID"], $custID);
}
$response["success"] = 1;
echo json_encode($response);
}else {
$response["success"] = 0;
$response["message"] = "No shipping found";
echo json_encode($response);
}
}else {
$response["success"] = 0;
$response["message"] = "No shipping found";
echo json_encode($response);
}
}