I'm trying to teach myself SQL/PHP by building a database driven local site for keeping track of my calibrated tools (lot of them).
Basically my table looks like this:
Table: calibrated_items
Fields: serial_number, part_number, location, nomenclature, calib_freq, date_calib
These tools have different intervals at which they need to be calibrated (180 days, 360 days, etc). I'm trying to figure out how I can query my list of tools and show how many days they have until due calibration. The date_calib field is a date field for when the tool was last calibrated (ie; 2013-07-24). calib_freq is the interval frequency for calibration (ie; 180 days).
I'm currently querying the database like this:
$callist = mysqli_query($con, "SELECT * FROM calibrated_items WHERE date_calib <= (NOW() - INTERVAL 180 DAY)");
I know this a jacked up way to try and accomplish what I'm aiming for. I just don't know enough to figure out how to use NOW() date_calib and and calib_freq to output a number of days until due field. I don't really need to save that field, I just want to output it to the webpage.
I hope I included enough information for this to make sense. If not, let me know. Thanks!