Re: PHP sort from .... best solution?
| From: | A. Lyse | Date: | Sun, 08 Jun 2003 21:12:42 +0000 |
| Subject: | Re: PHP sort from .... best solution? | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-28432@lists.php.net to get a copy of this message | ||
Hi again!
Is it possibile to only show articles from a sertain month. say I want to
show all articles from June 2003 (2003 01/06 - 2003 31/06)... the variable
here is "publisert"
It should be enough info over to help me :)
Regards,
A. Lyse
"A. Lyse" <allyse@hardware.no> wrote in message
news:20030605202047.98509.qmail@pb1.pair.com...
> Hi!
>
> Thanks! But I got a problem with the code:
>
> The PHP file as it is with the code pasted into it will i'll past at the
end
> of this post. The problem is I get the error:
>
> Warning: Invalid argument supplied for foreach() in
> /home/amotor/www/list_ingresser_artikler.php on line 43
>
> If I put a // in front of line 32 the script feeds correct, but not
sorted.
> I think there is a very easy solution to this, but I dont know so mutch
PHP
> :( I'm reading though.
>
> Thanx alot for the help I got so far. I've learned alot!
>
> Regards,
> A. Lyse
>
> The PHP file
> ********************
>
> <?php
> //Dette er en mal for å lette implementering av pusyset til de enkelte
> sider.
> //Denne malen viser ingressene til de 50 siste artikler denne siden skal
ha.
> include "../lib/ingress.lib";
>
> $nettstedid=11; //Id til nettstedet. Dersom man ikke husker sin nettstedid
> finnes den i admindelen av pubsyset.
> $sprakid=1; //Språkid. 1=Norsk
> $offset=0; //Offset, dersom man ikke skal vise fra artikkel 0, men f.eks.
> fra artikkel 51.
> $offset3ingr=2; //Offset, dersom man ikke skal vise fra artikkel 0, men
> f.eks. fra artikkel 51.
> $offsetannet=1; //Offset, dersom man ikke skal vise fra artikkel 0, men
> f.eks. fra artikkel 51.
> $antall=50; //Hvor mange artikler skal vises
> $antallmotor=25; //Hvor mange artikler skal vises på motorsport
> $antallmotor3ingresser=3; //Hvor mange artikler skal vises videre på
> motorsport
> $antallmc=1; //Hvor mange artikler skal vises på MC
> $antallmc3ingresser=3; //Hvor mange artikler skal vises videre på MC
> $antallstyling=1; //Hvor mange artikler skal vises på MC
> $antallstyling3ingresser=3; //Hvor mange artikler skal vises videre på MC
> $typeid=0; //Hva slags ingresser skal vises? "0" viser alle typer.
> $i1 = hentIngresser($nettstedid,38,$sprakid,$offset,$antallmotor);
> $i2 = hentIngresser($nettstedid,39,$sprakid,$offset,$antallmotor);
>
>
> function obj_date_compare($a, $b) {
> return strcmp($a->publisertLang, $b->publisertLang);
> }
>
>
>
> if($ingresser = array_merge($i1 ,$i2))
>
> {
> $ingresser = usort($ingresser, 'obj_date_compare');
> listIngresser($ingresser);
> }
>
>
> else
> echo 'Det oppstod en feil ved henting av ingresser.';
>
>
>
> function listIngresser($ingresser){
> foreach($ingresser as $i){
>
> echo '
> <tr>
> <td width="100%" align="left" bgcolor="#ebe8e4" > <a
> href="'.$i->artikkellink.'"> <img class=lesmer
> src="/bilder/design/lesmer.gif" width="61" height="19"
> align="right">
> <b> <a class=forsidelinker
> href="'.$i->artikkellink.'">'.$i->overskrift.'</a>
> </b>
> <b class=dato>('.$i->publisert.')</b>
>
> </tr> </td>
> <tr>
> <td height="121" class="ingresshoved">
> <a href="'.$i->artikkellink.'"><img class=bilde
> src="' . $i->bilde .
'"
> width="100" height="85" border="1"
> align="right"></a>
> </font>'.$i->ingress.'
>
> <tr> <td align="left" width="100%" bgcolor="#f4f4f4">
> <p>
> </p> </td> '
> ;
>
>
> }
> }
>
>
>
> ?>
>
>
> ************** END PHP file ***********
>
>