私は、簡単に機能するように見えるものを手に入れようと頭を悩ませてきました。私はテーブル「体重」を持っています。重量には、「shipping_to」、「shipping_from」、および「shipping_cost」の 3 つの列があります。
Shipping_to と Shipping_from は重量値で、値が X 以上かつ X 以下の場合、送料は送料を保持します。
私はこれを何百万もの異なる方法で書いてきましたが、私の人生ではうまくいきません。
更新: スクリプトは「ある程度」動作しますが、1 の成功応答を返すことはなく、これらの値を手動で MySQL データベースに入れても、X の値を見つけることはありません。
PHP スクリプト:
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);
}
}