son.of.the.morning Posted November 25, 2011 Share Posted November 25, 2011 I am using a query to select everything out of a table in to an array. I have 4 fields as follows name, email, comment and datatime. What i want to do is use one of the stated function to grab the datetime elements and split them at the break point, but i am displaying more than one record with in the table, i think this is were i am fucking up. for example i tryied this: $commentsTable = "comments"; $comments = "SELECT * FROM $commentsTable"; $commentResults = mysql_query($comments); $commentRows = mysql_fetch_array($commentResults); $dateTimeSplit = explode(" ", $commentRows['datetime']); <?php while($commentRows = mysql_fetch_array($commentResults)){?> <div id="comments"> <div id="CommentWrapper"> <div id="comment"> <div id="UserComment"><? echo $commentRows['comment'];?></div> // here is were am having the problem!!! <div id="PostDateTime"><i>Posted: </i><? echo $dateTimeSplit['0'];?><i> Time: </i><? echo $dateTimeSplit['1'];?></div> </div> </div> </div> <?php } mysql_close(); ?> any sudgestions? Link to comment https://forums.phpfreaks.com/topic/251782-using-explode-or-str_split-to-break-apart-a-datetime-data-type/ Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2011 Share Posted November 25, 2011 Just SELECT them as separate entities in the query string. SELECT DATE(`datetime`) as date, TIME(`datetime`) as time FROM `table` Link to comment https://forums.phpfreaks.com/topic/251782-using-explode-or-str_split-to-break-apart-a-datetime-data-type/#findComment-1291121 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.