Webmaster Forum

Go Back   Webmaster Forum > Web Development > Web Design Lobby

Web Design Lobby Forum for general web design issues not specific to scripting or graphics.


Reply
 
LinkBack Thread Tools Display Modes
Old 12-22-2008, 07:06 PM   #1 (permalink)
Contributing Member
 
Join Date: 12-14-08
Posts: 140
iTrader: 0 / 0%
Latest Blog:
None

2939195631902 is liked by many
Exclamation How could i store dates in sql as i upload pictures??

I'm trying to build a family website where family members could upload pictures. I know there are websites that allow us to do this, but i really want to build a personalized version myself.

Right now, i'm down to one problem. I'm trying to store the upload date into mysql and then sort the pictures by date when it appears on the website.

I have a pretty solid understanding of php and mysql, and i have thought of a way to accomplish this. However, my idea is really complex, unnecessary, and stupid.

This is much harder than i anticipated. Afterall, i can't exactly store dates in their format in mysql.

So if you got any good ways to accomplish this, i'll be pleased to hear them.
2939195631902 is offline  
Add Post to del.icio.us
Reply With Quote
Old 12-22-2008, 08:47 PM   #2 (permalink)
Meeow!
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 3,235
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest order
Assuming the table is named uploads and has a column named upload_date and the data type of this column is set to datetime having the default value set to "0000-00-00 00:00:00" ([y-m-d h:m:s] without quotes):

The insert query would look like:

PHP Code:
// INSERT
$query_insert mysql_query("INSERT INTO uploads(upload_date) VALUES(CURRENT_TIMESTAMP())"); 
And the select query:
PHP Code:
// SELECT
$query_select mysql_query("SELECT upload_date FROM uploads ORDER BY upload_date DESC");

// when displaying the date:
while ($info mysql_fetch_assoc($query_select))
{
    echo 
'<p>Image uploaded on: '.gmdate("Y m d"strtotime($info['upload_date'])).' @ '.gmdate("H:i:s"strtotime($info['upload_date'])).'"</p>';

^^ here you have to format how your date is displayed, I just used "Y m d" to get you started. more info(http://www.php.net/date)


give this a try and let us know how it went.
__________________
...to be continued
Costin Trifan is offline  
Add Post to del.icio.us
Reply With Quote
Old 12-23-2008, 05:51 AM   #3 (permalink)
Contributing Member
 
Join Date: 12-14-08
Posts: 140
iTrader: 0 / 0%
Latest Blog:
None

2939195631902 is liked by many
Thx man

That's is exactly what i was looking for.
2939195631902 is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What web host to use to have anyone upload pictures KMIGS Web Hosting Forum 10 09-14-2009 11:16 PM
customer upload image oscommerce store littleolemedesigns Web Design Lobby 4 12-02-2007 11:58 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 09:23 AM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.