We help IT Professionals succeed at work.

How would I use PHP to run two different type mysql querys and display the results in the same table ?

GD_GRAY
GD_GRAY asked
on
I need to run the two query's below and than echo the results as one table. Can anyone tell me how ? What I need to do is show along side the meter_date field the number of days it has been from today's date that it was last updated.
SELECT To_days( meter_date ) - TO_DAYS( last ) FROM `meter`


SELECT * FROM meter WHERE hub > 1 AND service_type ='Wet' ORDER BY meter_date DESC, unit ASC

Open in new window

Comment
Watch Question

IT Supervisor
Top Expert 2009
Commented:
How about doing the calculation along with the select:
SELECT meter.*, TO_DAYS(meter_date)-TO_DAYS(last) AS last_meter_update
FROM meter
WHERE hub > 1
  AND service_type = 'Wet'
ORDER BY meter_date DESC, unit ASC
;

Open in new window


Although I think you want your date calculation to be:
TO_DAYS(NOW())-TO_DAYS(meter_date)

Open in new window

Author

Commented:
Thank you...
LoL and yes your right, I did want the calculation the other way. You have a wonderful Christmas..