Reputation: 95
<?php
//run a select query to my latest 1 item
include "storescripts/connect_to_mysql.php";
// This block grabs the whole list for viewing
$dynamicList= "";
$sql = mysql_query("SELECT * FROM blog");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$title = $row["title"];
$author = $row["author"];
$category = $row["category"];
$article = $row["article"];
// $postdate = strftime("%b %d, %Y", strtotime($row["postdate"]));
$postdate = $row["postdate"];
//Seperate so it's easier to see what i'm working with here.
$short = substr(strip_tags($article), 0, 400);
$dynamicList .= '<ul>
<li>
<div class="wrapFirstRowBlog">
<div class="postDate">'.$postdate.'</div>
<div class="nextToDate">
<div class="blogTitle"><h3><a href="blog.php?id='.$id.'">'.$title.'</a></h3></div>
<div class="author">written by '.$author.' for the '.$category.' section.</div>
<div class="socialNetwork"></div>
</div>
</div>
<div class="blogPreview">
<img class="blogLeft" src="../blog_images/'.$id.'.jpg" width="150" height"150" alt="'.$title.'"/>'.$short.'...<a href="http://www.moniquetrinidadjewelry.com/images/new-images/read-more.png"><img src="http://www.moniquetrinidadjewelry.com/images/new-images/read-more.png" alt="read more of this post" /></a>
</div>
</li>
</ul>';
}
} else {
$dynamicList = 'Nothing posted yet...check back soon!';
}
mysql_close();
?>
I've tried many combinations searched everywhere here and I can do what I'm trying to do with it begin within my script. I'm trying to convert the date to simply show date. My mysql reading is
2013-06-03 00:18:32
and I'd like to simply cut that to show only the date and not time. I can't seem to figure out how to do it when it is within my script. I've tried
$postdate = strftime("%b %d, %Y", strtotime($row["postdate"]));
which is a containment of the row and can't figure it out. At what point should I be outputting these changes and any reference as to why would be greatly appreciated.
Upvotes: 2
Views: 622