Jump to content

using explode() or str_split() to break apart a DateTime data type


son.of.the.morning

Recommended Posts

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.