Forum Moderators: coopster
I'm wondering if anyone has some sample code on how to calculate a shipping price based on total weight to be shipped.
I am using php/mySQL, and each item has it's own weight in the database.
My question is this: how do you setup a table so that you can check if your $totalweight is between certain weights?
Would it just be something like this?
minweight ¦ maxweight ¦ shipcost
if so, how do you do a proper query to get that shipcost?
I imagine it would be something like this, but I need some help with the syntax.
$result = mysql_query("SELECT shipcost FROM shiptable WHERE $totalweight <= maxweight AND $totalweight >= minweight");
thanks,
Neil
SELECT
shipcost
FROM shiptable
WHERE $totalweight BETWEEN [dev.mysql.com] minweight AND maxweight
;
SELECT
shipcost
FROM shiptable
WHERE maxweight >= '$totalweight'
ORDER BY maxweight
LIMIT 1
;