Page 1 of 1
PHP MySql Question
Posted: Mon Sep 08, 2008 6:31 am
by hairytea
I hope this is ok place to post this question....(please correct me if not)....
I have table created on mysql database that records customer name, invoice number etc and there is one field i need a little help with...
i want one field to be able to give a timestamp on when the record was created and i also want to be able to view all customers in the database listing them in order of when the record was updated!
so lets say a icreate a field called date_joined - would i use the data type date or something and if this was used is it posssible to return the entries in the database in date ascending order?
Many thanks
Andrew
Re: PHP MySql Question
Posted: Mon Sep 08, 2008 6:34 am
by JAB Creations
It's either PHP or MySQL that has a
now function of sorts...
Code: Select all
$mysql_register = mysql_query("INSERT INTO public_accounts (username, password, email, activation_key, date_0, ip_0, status) VALUES ('$username', '$password', '$email', '$activation_key', NOW(), inet_aton('".$ipaddress."'), 'Activation Pending')");
Also use phpMyAdmin as it will
easily generate the code for you to learn from. Seriously, 90% of what I've learned about MySQL in the past couple months have come from messing with phpMyAdmin.
Re: PHP MySql Question
Posted: Mon Sep 08, 2008 6:39 am
by hairytea
thank you for your very prompt reply.
i do have phpmyadmin with this database so i will play.
just one quick question...
would it be more beneficial to have a user input (for me to insert a date) or just have a field that auto updates with the current date time etc?
Re: PHP MySql Question
Posted: Mon Sep 08, 2008 9:52 am
by JAB Creations
I use three fields for date, date_0, date_1, and date_2. The first is for registration only. The last is for the latest authentication while the second is for the previous authentication. I do the same thing for IP addresses and user agents.
Re: PHP MySql Question
Posted: Mon Sep 08, 2008 10:12 am
by jayshields
JAB Creations wrote:I use three fields for date, date_0, date_1, and date_2. The first is for registration only. The last is for the latest authentication while the second is for the previous authentication. I do the same thing for IP addresses and user agents.
Why do you need to know when your users were authenticated? And what is the difference between the latest authentication and the previous one?
Re: PHP MySql Question
Posted: Mon Sep 08, 2008 10:22 am
by JAB Creations
If you authenticated once yesterday and once today then date_2 is today's date and date_1 is yesterday's date.
If learning is the detection of patterns then there is no justification to not aid in the creation of patterns that could clearly aid me in the prevention of a multitude of abuses. Essentially any abuse puts an account in to an instant freeze status until I've had the chance to asses the situation. That means that if someone signs in to your account in example today I will see a clear contrast in the account's activity between today by the culprit and your previous activity.
Re: PHP MySql Question
Posted: Mon Sep 08, 2008 10:32 am
by hairytea
hi,
i think there is a bit of confusion here...
let me explain a little better....
the records i am inserting are for me to keep track of who registers as i am charging yearly subscription fees for the website. I want to be able to log in, add customer details and when necessary check the customers in the database in ascending order from when they were added! so, i will know what date each one was added and be able to notify customers when the years subscription has ended and contact them to hopefully re-subscribe.
i have written a script using timestamp now and all i need to do is be able to write the customers details to the html page in ascending order starting from first registered.
Sorry if i confused you with what i was asking.
here is the site:-
http://www.the3network.co.uk/thanet
Re: PHP MySql Question
Posted: Mon Sep 08, 2008 10:45 am
by hairytea
ok ok ok
i seee i can view all this information in phpmyadmin in any order i wish to without all the scripting etc.
PROBLEM SOLVED - TOPIC CLOSED
thank you