PF2G Posted July 6, 2012 Share Posted July 6, 2012 Hi, I'm creating a SELECT statement where i select the date and if it's from today or past day it appears if it isn't it doesn't appear. I have this code but it does nothing: $data_hj_antes=mysql_query("SELECT data FROM noticias WHERE data <= CURRENT_DATE() ORDER BY data DESC") or die(mysql_error()); $hj_antes=mysql_fetch_assoc($data_hj_antes); if ($hj_antes=mysql_fetch_assoc($data_hj_antes)) { echo "<h1 class='title' style='padding-top:10px;'>". $desc_atual['titulo']. "<div class='escrit' style='margin-top:-20px;'>"; if (mysql_num_rows($query_not_ant)>0) { echo "<a href='".$current_lang."/".$module."/".$id_ant."'>< ANTERIOR</a>"; } else { echo "< ANTERIOR"; } echo "   "; if (mysql_num_rows($query_next)>0) { echo "<a href='".$current_lang."/".$module."/".$id_nxt."'>SEGUINTE ></a>"; } else { echo "SEGUINTE >"; } echo "</div> </h1>"; echo '<div class="details">'; echo '<div class="descricao" style=" margin-left:15px; padding-bottom:15px;">'. $desc_atual['descricao'] .'</div>'; echo '</div>'; } Can some help me, please? Thank you PF2G Quote Link to comment https://forums.phpfreaks.com/topic/265324-all-news-except-future/ Share on other sites More sharing options...
Pikachu2000 Posted July 6, 2012 Share Posted July 6, 2012 What is the format of the date in the `data` field? Quote Link to comment https://forums.phpfreaks.com/topic/265324-all-news-except-future/#findComment-1359701 Share on other sites More sharing options...
PF2G Posted July 6, 2012 Author Share Posted July 6, 2012 What is the format of the date in the `data` field? Youre right i forgot, but now the content doesn't appear :S $link = mysql_query("SELECT id, str_to_date(data,'%d/%m%/%Y') AS date FROM noticias WHERE date <= CURDATE() ORDER BY date"); $row = mysql_fetch_array($link); if ($row = mysql_fetch_array($link)) { Quote Link to comment https://forums.phpfreaks.com/topic/265324-all-news-except-future/#findComment-1359704 Share on other sites More sharing options...
Pikachu2000 Posted July 6, 2012 Share Posted July 6, 2012 The question was in what format is the date currently stored in the `data` field? Also, what is the field type, DATE, DATETIME, VARCHAR? Quote Link to comment https://forums.phpfreaks.com/topic/265324-all-news-except-future/#findComment-1359705 Share on other sites More sharing options...
PF2G Posted July 6, 2012 Author Share Posted July 6, 2012 the date in the DB is varchar, when i add i transform it in the format date (%d/%m/%Y). Quote Link to comment https://forums.phpfreaks.com/topic/265324-all-news-except-future/#findComment-1359710 Share on other sites More sharing options...
Pikachu2000 Posted July 6, 2012 Share Posted July 6, 2012 Again you left out the most important part. What is the format in which the date is currently stored? Quote Link to comment https://forums.phpfreaks.com/topic/265324-all-news-except-future/#findComment-1359713 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.