MemHT Portal is a Free PHP CMS and Blog
It permit the creation and the management online of websites with few and easy steps.
It's completely customizable, expandable and suitable for all needs.
A2Hosting
Moderators: Moderators
Forum RSS feedReply
Help with Select
AuthorText
slashado
Donator

Posts: 323
Contributes: 350

Gender: _MALE_
Online: No

Version: 4.0.1
Country: Brasil
Languages: Português, Inglês (via Google), e todas as outras (via google)
Date: 07/09/2009 00:41
Help with Select
#post21918
Hello again Mem, Paul ...

'm All afternoon trying to figure out why the code I'm creating is not working on memht.
I've tried all kinds of SELECT as possible but always returns error messages in memht.
The code is as follows:
code

<?php
global $dblink;
$result = $dblink->get_list("SELECT *, date_format(date,'%d/%m/%Y') AS date FROM memht_calendar_events ORDER BY date ASC LIMIT 1");
        foreach ($result as $row) {
                $id = $row['id'];
                $data = $row['date'];
        $hoje = date("d/m/Y");
        $titulo = $row['title'];
    }
    if($data > $hoje){
    echo "<div align='center'>";
    echo "<div style='font-size:20px;'><b>Dia <font color='#990000'><blink>$data</blink></font></b></div><p>";
    echo "<div style='font-size:14px;'><b>$titulo</b></div></div><p>";
    }else{
    echo "<div align='center' style='font-size:16px;'><b>Não há Eventos!</b></div><p>";
    echo "<div align='center' style='font-size:16px;'><b>Aguarde Novidades!</b></div>";
    }
?>
 


This code I'm trying to create for him to catch only the future dates on the calendar of events MemHT, but anything I do, he continues to get older dates ...
For example: I have a record of the day 01/01/2009. Today is 06/09/2009, and have another record of 12/09/2009.
So he should only return me the date of 12.09.2009 as the first, is older than the current ... someone help me with my error? what is missing for that work?

#############################################

Estou a tarde inteira tentando adivinhar o motivo pelo qual o código que estou criando não está funcionando no memht.
Eu já tentei todo o tipo de SELECT possível mas sempre retorna mensagens de erro no memht.

Esse código, estou tentando criar para que ele pegue somente as datas FUTURAS no calendário de Eventos do MemHT, mas qualquer coisa que eu faça, ele continua a pegar datas mais antigas...
Por exemplo: tenho um cadastro do dia 01/01/2009. Hoje são 06/09/2009, e tenho outro cadastro de 12/09/2009.
Então, ele só deveria me retornar a data de 12/09/2009 já que a primeira, é mais antiga que a atual... alguém pode me ajudar com meu erro? o que está faltando pra isso funcionar?
..::MS Criações::.. - Criação e Hospedagem de Websites!
..::Memht BRASIL::.. - Comunidade brasileira do MemHT!
Soon, Virtual Store with Modules and Templates for MemHT!
Eager for MemHT 5
Delete Edit Quote
 
mem
MemHT's Dad
Admin & Developer

mem

Posts: 7243
Contributes: 4800

Gender: _MALE_
Online: No

Languages: English, Italiano, Македонски, Српски
Date: 07/09/2009 08:08
Re: Help with Select
#post21923
if($data > $hoje){ will not work, you're confronting 2 strings and that will return true if the string contained in $data is LONGER (not bigger, it's not a number) then the one in $hoje.

You should find $year, $month and $day and then confront them one by one
Follow me on twitter if you want to be updated on the MemHT 5 development.
Delete Edit Quote
 
slashado
Donator

Posts: 323
Contributes: 350

Gender: _MALE_
Online: No

Version: 4.0.1
Country: Brasil
Languages: Português, Inglês (via Google), e todas as outras (via google)
Date: 07/09/2009 19:47
Re: Help with Select
#post21930
Actually, I was calculating dates as if they were numbers ... I changed the code now and it worked, thank you Mem!

Here is the code for who ever need to:
code

<?php
global $dblink;
$result = $dblink->get_list("SELECT *, date_format(date,'%Y/%m/%d') AS date FROM memht_calendar_events ORDER BY date DESC LIMIT 1");
        foreach ($result as $row) {
                $id = $row['id'];
                $data_db = $row['date'];
        $titulo = $row['title'];
    }
$hoje = date("Y/m/d");
$pri = explode("/", $data_db);
$seg = explode("/", $hoje);
$Mpri = $pri[2]."/".$pri[1]."/".$pri[0];
$Mseg = $seg[2]."/".$seg[1]."/".$seg[0];
   
    if($data_db >= $hoje){
    echo "<div align='center'>";
    echo "<div style='font-size:20px;'><b>Dia <font color='#990000'><blink>$Mpri</blink></font></b></div><p>";
    echo "<div style='font-size:14px;'><b>$titulo</b></div></div><p>";
    }else{
    echo "<div align='center' style='font-size:12px;'><b>Não há Eventos!</b></div><p>";
    echo "<div align='center' style='font-size:12px;'><b>Aguarde Novidades!</b></div>";
    }
?>
 
..::MS Criações::.. - Criação e Hospedagem de Websites!
..::Memht BRASIL::.. - Comunidade brasileira do MemHT!
Soon, Virtual Store with Modules and Templates for MemHT!
Eager for MemHT 5
Delete Edit Quote
 
mem
MemHT's Dad
Admin & Developer

mem

Posts: 7243
Contributes: 4800

Gender: _MALE_
Online: No

Languages: English, Italiano, Македонски, Српски
Date: 07/09/2009 19:52
Re: Help with Select
#post21931
The problem is that you're still using $data_db and $hoje while you should exploded data
Follow me on twitter if you want to be updated on the MemHT 5 development.
Delete Edit Quote
 
slashado
Donator

Posts: 323
Contributes: 350

Gender: _MALE_
Online: No

Version: 4.0.1
Country: Brasil
Languages: Português, Inglês (via Google), e todas as outras (via google)
Date: 07/09/2009 20:12
Re: Help with Select
#post21933
But hey so I found in php.net manual.

I really find it odd that their example, but oddly enough, this time it worked!
Mem, as would be the correct format to use this function? you can show how I have done?SmileSmile
Edited: 07/09/2009 20:13
..::MS Criações::.. - Criação e Hospedagem de Websites!
..::Memht BRASIL::.. - Comunidade brasileira do MemHT!
Soon, Virtual Store with Modules and Templates for MemHT!
Eager for MemHT 5
Delete Edit Quote
 
Reply
Tags Cloud
Twitter updates...
Help MemHT Portal
Navigator
Users Block
Hi Guest
IP: 38.107.179.230

Username
Password
MemHT Wiki
Language
MemHT Portal is a free software released under the GNU/GPL License by Miltenovik Manojlo