Log in

View Full Version : month events...



pavmoxo
05-16-2006, 12:06 PM
If I have:



...
$sql = "select * from agenda_geral where agenda='desporto' and Bmonth = (month(now())+1) + ".$modifier." and area_ID = 1 order by Bday" ;
$queryl = query($sql) or die ("Query failed: " . mysql_error() . " Actual query: " . $sql);
$contal = mysql_num_rows($queryl);


for ($j=0; $j<1;$j++)
{
$arrl = mysql_fetch_array($queryl);...

and I want if there aren't no events in the next month the link not appears. What should I do in the next code?


<? if( $arrl["Bmonth"] == NULL) {?>
<a></a>
<? } else { ?>
| <a href="agend_desporto.php?modifier=1"> Seguinte </a>
<? } ?>

cybercoder
05-20-2006, 04:33 PM
Well you would not test for a NULL value:


<? if( $arrl["Bmonth"] == NULL) {?>

You would test for nothing...But all we need to do is test for the true value, a month:


<? if( $arrl["Bmonth"] ) {?>
| <a href="agend_desporto.php?modifier=1"> Seguinte </a>
<?php
}

Have fun :)

pavmoxo
05-22-2006, 10:02 AM
But i don't understand what it's happen!!

Bmonth = month(now()) in my querie but I wan't to verify if exists a register in the next month in DB for show the word "Seguinte". I don&#180;t know what to do more.

Code:


<?
<?
$conn = mysql_connect(SERVER,DBUSER,DBPWD) or die ("Problemas na liga&#231;&#227;o MySQL");
mysql_select_db (DB);
$modifier = isset($_GET['modifier']) ? mysql_real_escape_string($_GET['modifier'], $conn) : 0;
$day = date(d);
if($day < 25)
$sql = "select * from agenda_geral where agenda='desporto' and Bmonth = month(now()) + ".$modifier." and area_ID = 1 order by Bday" ;
else
$sql = "select * from agenda_geral where agenda='desporto' and Bmonth = (month(now())+1) + ".$modifier." and area_ID = 1 order by Bday" ;
$queryl = query($sql) or die ("Query failed: " . mysql_error() . " Actual query: " . $sql);
$contal = mysql_num_rows($queryl);


for ($j=0; $j<1;$j++)
{
$arrl = mysql_fetch_array($queryl);
?>
<h1>Desporto - <? echo trata_month($arrl["Bmonth"])." de ".$arrl["Byear"]; ?></h1>


<!-- ALTERNATIVA-->
<p>
<? if($modifier == -1) {?>
<a href="agend_desporto.php?modifier=0"> Actual </a>
<?
$next_month= $arrl["Bmonth"];
echo $next_month;

if($arrl["Bmonth"]) {?>
| <a href="agend_desporto.php?modifier=1"> Seguinte </a>
<? } ?>


<?
}
elseif($modifier == 0)
{
?>
<a href="agend_desporto.php?modifier=-1"> Anterior </a> |
<a href="agend_desporto.php?modifier=0"> Actual </a>
<?
$next_month= $arrl["Bmonth"];
echo $next_month;
if($arrl["Bmonth"]) {?>
| <a href="agend_desporto.php?modifier=1"> Seguinte </a>
<? } ?>
<? }
elseif($modifier == 1)
{
?>
<a href="agend_desporto.php?modifier=-1"> Anterior </a> |
<a href="agend_desporto.php?modifier=0"> Actual </a>
<? } ?>


</p>
<? } ?>