Jump to content

Muffy

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Muffy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. OK I've got the code that I want! I've gone with the TIMEDATE format. From what I've read (thanks for the links) it seems to be the better one to go with. In regards to this intention: I've read the MySQL Date and Time functions (thanks for the link obsidian) and have found the MySQL functions to be extremely valuable!! For those interested, here's my SQL statement: $query = " SELECT title, body, author, authorID, publishedDate, categoryID, categories.name AS category, subCategoryID, subCategories.name AS subCategory, articles.genreID, genre, DATEDIFF(NOW(), publishedDate) AS dateDifference, DATE_FORMAT(articles.publishedDate, '%h %i %p') AS pubTime, DATE_FORMAT(articles.publishedDate, '%D %M %Y') AS pubDate FROM articles LEFT JOIN categories ON articles.categoryID = categories.catID LEFT JOIN subCategories ON articles.subCategoryID = subCategories.subCatID LEFT JOIN genres ON articles.genreID = genres.genreID WHERE articles.articleID = ". $articleID From that I get a table that has 3 appended columns: dateDifference, pubTime and pubDate. With PHP I can manipulate the output like this: $output = "Submitted by ". $row['author'] ." "; if ($row['dateDiff']) { $output .= "on ". $row['pubDate']; } else { $output .= "at ". $row['pubTime']; } echo $output ."."; So thanks to obsidian and Zaid for your help!
  2. I'm trying to give a user the ability to post comments and articles. Each post will carry a date. So I'm trying to figure out the best way to store the dates and retrieve them for output. I'm also thinking about comparing dates so in the circumstance that an article is viewed on the same day that it is posted it will display the time of post instead of the date of post. I'm only able to sit at the PC right now for 5 minutes (gotta go to work... ugh) but I've just had a quick look at those functions. They look extremely useful. I'll have a bit of a play when I get back from work and post my results. Cheers!
  3. OK fair enough. So if I'm to use the timestamp data type in MySQL, does that mean that I'll need to use the strtotime($date) function every time I use a date? It seems that if I don't use that I end up with the 1970 date.
  4. I've read that it's best to store your dates in the Unix Timestamp format using the strtotime($date) command (read here). How should I best setup the field in my MySQL table? Should I use a VARCHAR, and if so how big?
  5. Thanks guys that exactly what I'm after.
  6. Is it possible to use PHP to grab URL of the current page and put in into a variable? ie. If I'm viewing: http://localhost/mypage/index?article=23 Can I put "http://localhost/mypage/index?article=23" into a variable?
  7. touché. Thanks for the suggestions. I've just played around with sessions and it's just what I want. Thanks!
  8. Is there any way to do this (below code) without using the POST method (ie. is there a more discreet method where the "?problem=true" doesn't need to show in the URL)? if ($noProblems) { header("Location: index.php"); } else { header("Location: index.php?problem=true"); }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.