Re: PHP sort from a database variable..?
| From: | heilo | Date: | Tue, 03 Jun 2003 21:40:46 +0000 |
| Subject: | Re: PHP sort from a database variable..? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-28266@lists.php.net to get a copy of this message | ||
hi!
we need information about how the array looks like!
please add the following to your script (after merging $i1 and $i2):
echo '<pre>';
print_r($ingresser);
echo '</pre>';
and send the resulting output!
you can use array_multisort for this problem. anyways i propose to write
your own news-tool. sorting is really easy if you use SQL - if you cant code
one yourselve i would ask the programmer of this newsmodule to add a
sort-parameter to his functions.
.ma
A. Lyse <allyse@hardware.no> wrote@03.06.2003 23:23 Uhr:
> Please dont kill me for posting here. I dont know where else to post. I'm a
> newbie and is completly stuck with a php problem :(
>
> I got this code (among with more though...):
>
> ***********************
> $i1=hentIngresser($nettstedid,38,$sprakid,$offsetannet,$antallmotor);
> $i2=hentIngresser($nettstedid,39,$sprakid,$offsetannet,$antallmotor);
>
>
> if($ingresser = array_merge($i1 ,$i2))
> listIngresser($ingresser);
>
>
> else
> echo 'Det oppstod en feil ved henting av ingresser.';
> **************************
>
> This code produce the article feeds on this site:
> http://www.amotor.no/artikler.php
>
> The articles are feeded from $i1 and $i2, but as you can see on the dates
> the newest article does not come first (the code first lists the $i1 THEN
> $i2) but what I want is to get the newest on date first, then older and
> older.
>
> I talked to the owner of the script and he said that he had a variable named
> "$publisertLang; //Publish date of the article in format: yyyymmddhhmmss"
> He said I could sort the "$ingresser" (the merged $i1 and $i2) with the
> $publisertLand as parameter on listIngresser, but the problem I dont know
> how to do that. I've looked through php.net and tryed all sort commands I've
> found.
>
> Can somebody please help me?
>
> P.S Excuse my bad English. It's not my native language.
>
> Regards,
> A. Lyse
>
>