title: PHP Select Value in MySQL Using Greater Than and Less Than
body: <p>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".</p>
  
  <p>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.</p>
  
  <p>I have written this a million different ways and for the life of me it won't work.</p>
  
  <p>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.</p>
  
  <p>PHP SCRIPT:</p>
  
  <pre><code>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 &gt;= '$ship_weight' AND to_weight &lt;= '$ship_weight'");
  
      if(!empty($result)){
          if (mysql_num_rows($result) &gt; 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);
      }
  }
  </code></pre>