finally got the SQL working, will finish interface to db tonight