3 answers:
Question 1) This question is confusing and ambiguous as you have written it.
Question 2) This question is very confusing as you have written.
For both of these questions help us by saying
what you want to happen,
your method for making it happen,
results you expected,
the unexpected results you actually got instead.
Question 3) Inserting the time spent would be simple like:
"INSERT INTO visit_tracking SET hours='1', minutes='22'"
Figuring out how long the user stayed on your sight in the first place? That, sadly, is difficult, practically impossible, and will not be accurate. You can create a javascript script based on browser "unload" events. Many browser will short circuit this event. Also, users who simply turn off their computers, or freeze up, etc., would never send an unload event even if their browsers allow it...so if you are starting a clock when the enter your site, the clock will never stop running.