I am facing one issue. I need to check value which should present within two column values using PHP and MySQL. I am explaining my table below.
id zip_from zip_to
1 751001 751030
db_postcode:
$post_code='751010';
$sql="select * from db_postcode where zip_from >='".$post_code."' and zip_to='".$post_code."'";
$sqlpin=mysqli_query($conn,$sql);
if (mysqli_num_rows($sqlpin) > 0) {
$data=array("status"=>"Success","msg"=>"Product is available for this postcode");
}else{
$data=array("status"=>"Failed","msg"=>"Product is not available for this postcode");
}
echo json_encode($data);
Here I am getting the message {"status":"Failed","msg":"Product is not available for this postcode"} which is wrong because code 751010 is present within 751001-751030. Here I need to check the user given value should be present within that two column.
zip_fromaINTcolumn? And why do you think that this is related to PHP?zip_to =, but i think you needzip_to <=.varchar.