Jump to content

All news except "future"


PF2G

Recommended Posts

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."'>&lt ANTERIOR</a>";
							}
							else
							{
								echo "&lt ANTERIOR";
							}

							echo "&nbsp &nbsp";

							if (mysql_num_rows($query_next)>0)
							{
								echo "<a href='".$current_lang."/".$module."/".$id_nxt."'>SEGUINTE &gt</a>";
							}
							else
							{
								echo "SEGUINTE &gt";
							}

						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

Link to comment
https://forums.phpfreaks.com/topic/265324-all-news-except-future/
Share on other sites

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))
			{

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.