PHP MySql Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hairytea
Forum Commoner
Posts: 92
Joined: Mon Feb 04, 2008 8:31 am

PHP MySql Question

Post 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
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: PHP MySql Question

Post 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.
hairytea
Forum Commoner
Posts: 92
Joined: Mon Feb 04, 2008 8:31 am

Re: PHP MySql Question

Post 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?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: PHP MySql Question

Post 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.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: PHP MySql Question

Post 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?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: PHP MySql Question

Post 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.
hairytea
Forum Commoner
Posts: 92
Joined: Mon Feb 04, 2008 8:31 am

Re: PHP MySql Question

Post 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
hairytea
Forum Commoner
Posts: 92
Joined: Mon Feb 04, 2008 8:31 am

Re: PHP MySql Question

Post 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
Post Reply