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
 
Thread Tools Display Modes
Share |
  #1  
Old 12-22-2008, 07:06 PM
2939195631902 2939195631902 is offline
Contributing Member
 
Join Date: 12-14-08
Posts: 140
iTrader: 0 / 0%
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.
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 12-22-2008, 08:47 PM
kos's Avatar
kos kos is offline
Coding Tiger
 
Join Date: 04-13-07
Location: .ro
Posts: 4,029
iTrader: 3 / 100%
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.
 
Reply With Quote
  #3  
Old 12-23-2008, 05:51 AM
2939195631902 2939195631902 is offline
Contributing Member
 
Join Date: 12-14-08
Posts: 140
iTrader: 0 / 0%
Thx man

That's is exactly what i was looking for.
 
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

Forum Jump

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 10:16 PM
customer upload image oscommerce store littleolemedesigns Web Design Lobby 4 12-02-2007 11:58 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 08:48 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC