PHP - Moved: Order Mysql Output By Date
This topic has been moved to MySQL Help.
http://www.phpfreaks.com/forums/index.php?topic=345631.0 Similar TutorialsHello, I would like to order by date that contains day and month, like this: 14-3 Is this possible? Quote $sql = mysql_query("SELECT * FROM date WHERE online='1'"); This topic's house has been seized by the bank and it now lives in MySQL Help until it can get back on its feet. http://www.phpfreaks.com/forums/index.php?topic=358035.0 Hello dear members, first of all sorry for my grammer i'm from Switzerland .
So now: I have a problem with php. I want to put out the date of a blogpost in this format dd:mm:yyyy instead of yyyy:mm:dd. I tried it a long time and used many different ways like: date, dateformat, strto etc. but at the and nothing worked for me. So here is a picture of the blogpost and i'll add the file with my compressd php code.
I'd be glad if you could help me
Regards Mr_Ironic This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=347726.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=320026.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=349226.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=312690.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=321906.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=328623.0 How can I make this output in descending order from greatest to least? Right now, it appears like: 1940 1941 1942 1943 1944 etc... i'd like it to be like 2012 2011 2010 2009 etc.. until it gets to 1940 any ideas? here is my code: <? $i = 1939; while ($i < 2012) { $i++; echo '<option value="'.$i.'">'.$i.'</option>'; } ?> I have this code Code: [Select] $nArr = array('A', 'B', 'C', 'D', 'E', 'F'); $counter = 3; while ($counter > 0) { $chunkedValues[$counter][0] = 1; for ($j = 0 ; $j < $counter ; $j++) { $chunkedValues[$counter][$j + 1] = $nArr[$j]; } $nArr = array_slice($nArr, $counter--); } var_dump($chunkedValues); that outputs: Code: [Select] array 3 => array 0 => int 1 1 => string 'A' (length=1) 2 => string 'B' (length=1) 3 => string 'C' (length=1) 2 => array 0 => int 1 1 => string 'D' (length=1) 2 => string 'E' (length=1) 1 => array 0 => int 1 1 => string 'F' (length=1) But i need this index structu Code: [Select] array 0 => array 0 => int 1 1 => string 'A' (length=1) 2 => string 'B' (length=1) 3 => string 'C' (length=1) 1 => array 1 => int 1 2 => string 'D' (length=1) 3 => string 'E' (length=1) 2 => array 2 => int 1 3 => string 'F' (length=1) I want to avoid loops with ceil. Any idea? thanks for your time. Greetings! I am really stock on this situation. 1. I have a variable $uc_order_created. 2. I have a code like this: <b><?php echo t('Due Date:'); ?></b> </td> <td width="98%"> <?php $duedate = mktime(0,0,0,date("m"),date("d")+30,date("Y")); echo "".date("F jS Y", $duedate);?> 3. How do I code if I want the result of $uc_order_created get displayed as Due Date using the code above? Or other modifications? 4. The situation now, the code is working when printing the invoice but its not based on $uc_order_created. So, every time I will edit the Order because of the change of items among others the Due Date will also update. All I want that when Order is edited the value of Due Date will still remain based on the $uc_order_created. Thank you so much in advance for your help. I have 2 tables I have settup called Users_Messages and Users_Message_Replies inside each of these tables I have a row called DateSent, I'm trying to select from both of these tables and only display the latest Sent item by ID and order them all by date. I can get it to display the items correctly using the below code, but I can't get them to order correctly by the latest date in both of the Tables. Code: [Select] $page_query = mysql_query(" SELECT MessageID, DateSent FROM Users_Messages WHERE ToID = '$user_ID' UNION SELECT MessageID, DateSent FROM Users_Messages WHERE FromID = '$user_ID' ORDER BY DateSent DESC "); while ($replycheck = mysql_fetch_assoc($page_query)){ $message_idmainnew = $replycheck['MessageID']; $date = $replycheck['DateSent']; $sql2 = "SELECT MainMessageID FROM Users_Message_Replies WHERE MainMessageID = '$message_idmainnew '"; $sql_result2 = mysql_query($sql2); $replycheck2 = mysql_fetch_assoc($sql_result2); $newreplyID = $replycheck2['MainMessageID']; $sql4 = "SELECT MessageID FROM Users_Messages WHERE MessageID= '$message_idmainnew'"; $sql_result4 = mysql_query($sql4); $messagecheck2 = mysql_fetch_assoc($sql_result4); $newmessageID = $messagecheck2['MessageID']; if ($newreplyID == NULL){ $sql2 = "SELECT * FROM Users_Messages WHERE MessageID= '$newmessageID' ORDER BY DateSent ASC"; $sql_result2 = mysql_query($sql2); $message_row = mysql_fetch_assoc($sql_result2); $message_01 = $reply_row['Message']; $date = $reply_row['DateSent']; $date1 = strtotime($date); $datemain = date('F j, Y, g:i a', $date1); }else{ $sql2 = "SELECT * FROM Users_Message_Replies WHERE MessageID= ' $newreplyID ' ORDER BY DateSent DESC"; $sql_result2 = mysql_query($sql2); $reply_row = mysql_fetch_assoc($sql_result2); $message_01 = $reply_row['Message']; $date = $reply_row['DateSent']; $date1 = strtotime($date); $datemain = date('F j, Y, g:i a', $date1); } { Is there an easier way to do this? And how would I get the dates to line up, with a Join? Thanks. Hi all I have a PHP script with the following var print $date; at the moment it is formatting the date like 03-24-2010 is it possible to get PHP to switch the date and month, so it looks like 24-03-2010 Thanks I am getting this error when I output a formatted date... Quote Warning: date() expects parameter 2 to be long, string given in I am using DATETIME. What do I need to do to fix things? Here is my code... Code: [Select] echo '<p class="commentDate">' . date($createdOn, 'g:ia') . ' on ' . date($createdOn, 'M j, Y') . '</p>'; Debbie I have a posting system worked out, as well as my database configured to my linking.. But as of right now, my posts are posted from oldest to newest, having users scroll down or go to the next page to see the most recent post.
How would I "flip" that around and make my posts start from newest to oldest by its date/time (Which is stored in the database)?
Thanks!
I have tried a large number of "solutions" to this but everytime I use them I see 0000-00-00 in my date field instead of the date even though I echoed and can see that the date looks correct. Here's where I'm at: I have a drop down for the month (1-12) and date fields (1-31) as well as a text input field for the year. Using the POST array, I have combined them into the xxxx-xx-xx format that I am using in my field as a date field in mysql. <code> $date_value =$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day']; echo $date_value; </code> This outputs 2012-5-7 in my test echo but 0000-00-00 in the database. I have tried unsuccessfully to use in a numberof suggested versions of: strtotime() mktime Any help would be extremely appreciated. I am aware that I need to validate this data and insure that it is a valid date. That I'm okay with. I would like some help on getting it into the database. hello I am trying to print a query out into a table that is grouped and styled by date. If the same date appears I want to style the row similar. Here is what I have: <table class="signup-sched"> <tr><th>signup date</th><th>Name</th><th>Notes</th></tr> <?php $myrows = $wpdb->get_results("SELECT `datefield-256` as signupdate, `your-name` as name, `your-email` as email, `your-message` as notes FROM wp_cc3_signup WHERE DATE_FORMAT(`datefield-256`, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m') ORDER BY `datefield-256`"); $sd = ''; if(count($myrows)){ foreach($myrows as $m){ if ($m->signupdate != $sd){ if ($sd != ''){ echo '<tr class="b"><td>'.$m->signupdate.'</td><td>'.$m->name.'</td><td>'.$m->notes.'</td></tr>'; } echo '<tr class="n"><td>'.$m->signupdate.'</td><td>'.$m->name.'</td><td>'.$m->notes.'</td></tr>'; $sd = $m->signupdate; } } } ?> </table> What am I doing wrong? how do i grab and print on page in date order all .jpg files in a folder ? Hello, Im trying to work out some code. On my site between Thursday 12th July and Sunday 15th July between the hours of 22:00 and 23:00 I want to display some code. I've done this so far, but am having trouble. Anyone please help? $the_date = date("H:i:s"); $timesep = explode(":",$the_date); // $hour = $timesep[0]; if (($the_date > 2010-08-12 && < 2010-08-15) && ($hour >= 22) && ($hour <= 23)) { //Code } |