View Full Version : Month events
pavmoxo
04-24-2006, 05:43 PM
I have registers in a mysql DB and I want to show them for months. I think I have a var like this:
$id = "month(now())";
$sql = "select * from agenda_geral where agenda='desporto' and month = ".$id." and area_ID = 1 order by day" ;
But what I have to do for show the next or the previous month events in the same page without create a new??
Tried:
$sql = "select * from agenda_geral where agenda='desporto' and month = ".$id+1." and area_ID = 1 order by day" ;?
pavmoxo
04-26-2006, 09:40 AM
But how can I change the month with links?
Example:
<p><a href="agend_desporto.php??????"> Previous </a> | <a href="agend_desporto.php??????"> Next </a></p>
Ah, I see.
$modifier = isset($_GET['modifier']) ? mysql_real_escape_string($_GET['modifier'], $conn) : 0;
$sql = "select * from agenda_geral where agenda='desporto' and month = ".$id+$modifier." and area_ID = 1 order by day";... where $conn is the resource handler for the connection to the database (the return value of mysql_connect or _pconnect).
pavmoxo
04-26-2006, 05:13 PM
Sorry!! I don't understand!!!
What about the links?? What should I put for pass for the previous or for the next month like a calendar??
For a previous month:
agend_desporto.php?modifier=-1For the next month:
agend_desporto.php?modifier=1For a year ago:
agend_desporto.php?modifier=-12For seven months from now:
agend_desporto.php?modifier=7
pavmoxo
04-27-2006, 09:27 AM
$conn = mysql_connect(SERVER,DBUSER,DBPWD) or die ("Problemas na ligação MySQL");
$id = "month(now())";
$modifier = isset($_GET['modifier']) ? mysql_real_escape_string($_GET['modifier'], $conn) : 0;
$sql = "select * from agenda_geral where agenda='desporto' and month = ".($id+$modifier)." and area_ID = 1 order by day" ;
$queryl = query($sql) or die ("Query failed: " . mysql_error() . " Actual query: " . $sql);
echo ($id + $modifier);
The test echo below gives 1 when I click <a href="agend_desporto.php?modifier=1"> Previous </a> and -1 when I click <a href="agend_desporto.php?modifier=-1"> Previous </a>
Why doesn't gives the actual month minus or plus the modifier??
pavmoxo
04-27-2006, 10:09 AM
It´s fix.
But I have another question...how can I increment or decrement the var modifier for pass to others months like a calendar, when I click several times on a link?
That's impossible (or very difficult, at least). You'd have to modify the link.
pavmoxo
05-02-2006, 04:53 PM
At this moment I have:
<p>
<a href="agend_desporto.php?modifier=-1"> Anterior </a> |
<a href="agend_desporto.php?modifier=0"> Actual </a> |
<a href="agend_desporto.php?modifier=1"> Seguinte </a>
</p>
And I tried to do with months:
<p>
<a href="agend_desporto.php?modifier=-3"> <? //echo trata_month($arrl["month"]-3) ?> </a><br />
<a href="agend_desporto.php?modifier=-2"> <? //echo trata_month($arrl["month"]-2) ?> </a><br />
<a href="agend_desporto.php?modifier=-1"> <? //echo trata_month($arrl["month"]-1) ?> </a><br />
<a href="agend_desporto.php?modifier=0"> <? //echo trata_month($arrl["month"]) ?> </a><br />
<a href="agend_desporto.php?modifier=1"> <? //echo trata_month($arrl["month"]+1) ?> </a>
</p>
function trata_month($data)
{
switch ($data){
case 1:
$data = "Janeiro";
break;
case 2:
$data= "Fevereiro";
break;
case 3:
$data = "Março";
break;
case 4:
$data = "Abril";
break;
case 5:
$data = "Maio";
break;
case 6:
$data = "Junho";
break;
case 7:
$data = "Julho";
break;
case 8:
$data = "Agosto";
break;
case 9:
$data = "Setembro";
break;
case 10:
$data = "Outubro";
break;
case 11:
$data = "Novembro";
break;
case 12:
$data = "Dezembro";
break;
}
return $data;
}
When I do that some months modify or doesn't appear. Why?? What can I do correct this code?
Easier:
function trata_month($mes) {
$months = array("", "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro");
return $months[$mes];
}And:
<p>
<?php for($i=-3;$i<2;$i++) { ?>
<a href="agend_desporto.php?modifier=<?php echo($i); ?>"><?php echo(trata_month($arrl["month"]+$i)); ?></a><br />
<?php } ?>
</p>
pavmoxo
05-03-2006, 10:41 AM
I continue to have the same problems:
Example:
Load Page shows
Fevereiro
Março
Abril
Maio
Junho
When I press Maio shows:
Fevereiro
Março
Abril
Maio
Junho
When I press Junho :
Janeiro
Sometimes when I click a month, it not corresponds
Could you link to the page? And its source?
pavmoxo
05-03-2006, 11:16 AM
yes!!!
Then will you please do so? :)
pavmoxo
05-03-2006, 11:28 AM
Sorry but it's local and can´t link. Can I send the script to you??
Post it here, as an attachment.
pavmoxo
05-03-2006, 11:52 AM
332
change extension to php to see better!!
Since I'm missing dados.php, functions.php and your database, that's a bit tricky.
How about those two files? And perhaps a mysqldump of that database?
pavmoxo
05-03-2006, 02:24 PM
333
334
I can´t give you dados.php but it only have DEFINES of mysql_connect
You never call mysql_select_db().
pavmoxo
05-03-2006, 05:16 PM
I put mysql_select_db() in agend_desporto.php and the result is the same one!!!! Any more idea??
pavmoxo
05-03-2006, 05:33 PM
Resume output:
http://10.0.0.9/cm-lousa.pt/2.0/agend_desporto.php?modifier=0
Fevereiro
Março
Abril
Maio
Junho
http://10.0.0.9/cm-lousa.pt/2.0/agend_desporto.php?modifier=-1
Janeiro
Fevereiro
Março
Abril
Maio
In this case, if I click in Abril, it goes to Maio
If i click in Fevereiro, it goes to Março and shows:
Janeiro
Fevereiro
Março
Abril
and so on.
You understand the problem?!!
I see the problem, but I'm pretty much stumped. Maybe someone else can spot the problem -- I'm sure it's something simple.
djr33
05-04-2006, 07:41 PM
I'd take a look, but the pages are timing out for me, sadly.
Yeah, me too. I had to reconstruct it on my desktop.
djr33
05-04-2006, 07:51 PM
Ah. Fun, heh.
I've looked at this, and I'm confused. If you can't figure it out, I most likely can't, anyway.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.