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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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