 |
|
|
12-22-2008, 12:57 PM
|
PHP sort content by date
|
Posts: 90
|
I believe there is a way to sort content by date. At the moment I have the array
PHP Code:
0 => "Actionscript 2 Preloader,preloader.swf,preloader.zip,A simple flash preloader to show users that the rest of a flash file is loading.,1.84 MB,06.12.2008,flash",
1 => "Flash RSS Feed Reader,rssreader.swf,rssreader.zip,Keep up with the news or any rss feed with a flash based RSS Reader.,14.9 KB,06.12.2008,flash",
etc... and
PHP Code:
list($title,$filename,$zipname,$content,$filesize,$dateadded,$type) = split(",", $varsarr[$theget]);
is there any way of taking the $dateadded value and sorting the content with it
__________________
Free Flash designs and tutorials at Please login or register to view this content. Registration is FREE
Shorten your URL's with Please login or register to view this content. Registration is FREE
|
|
|
|
12-22-2008, 03:54 PM
|
Re: PHP sort content by date
|
Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
|
PHP Code:
$array = array(0 => "Actionscript 2 Preloader,preloader.swf,preloader.zip,A simple flash preloader to show users that the rest of a flash file is loading.,1.84 MB,06.12.2008,flash", 1 => "Flash RSS Feed Reader,rssreader.swf,rssreader.zip,Keep up with the news or any rss feed with a flash based RSS Reader.,14.9 KB,06.12.2008,flash");
function cmp($a,$b){ list($title,$filename,$zipname,$content,$filesize,$dateadded,$type) = split(",", $a); list($title2,$filename2,$zipname2,$content2,$filesize2,$dateadded2,$type2) = split(",", $b); $dateadded = str_replace(".","",$dateadded); $dateadded2 = str_replace(".","",$dateadded2); return ($dateadded-$dateadded2); }
usort($array, "cmp");
I think this will sort ascending.
It looks quite ugly though. :P
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
|
|
|
|
12-22-2008, 04:00 PM
|
Re: PHP sort content by date
|
Posts: 90
|
is there no easier way to just get php to sort dates. attached is my file of what i have so far
__________________
Free Flash designs and tutorials at Please login or register to view this content. Registration is FREE
Shorten your URL's with Please login or register to view this content. Registration is FREE
Last edited by xuroq; 12-22-2008 at 04:02 PM..
|
|
|
|
12-25-2008, 05:19 PM
|
Re: PHP sort content by date
|
Posts: 90
|
hello?!?!?
__________________
Free Flash designs and tutorials at Please login or register to view this content. Registration is FREE
Shorten your URL's with Please login or register to view this content. Registration is FREE
|
|
|
|
12-25-2008, 07:57 PM
|
Re: PHP sort content by date
|
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
|
In order to sort by an element in an array, you are going to have to use a sort function.
__________________
<mgraphic /> - I don't have a solution but I admire the problem.
|
|
|
|
12-26-2008, 04:23 AM
|
Re: PHP sort content by date
|
Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
|
Have you actually tried the code I posted?
Because I think it works...
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
|
|
|
|
12-27-2008, 09:36 AM
|
Re: PHP sort content by date
|
Posts: 90
|
yes i have tried the code but this means I have to make a new line of code for each array. I already have the dates, I just want the php to sort them and display them
__________________
Free Flash designs and tutorials at Please login or register to view this content. Registration is FREE
Shorten your URL's with Please login or register to view this content. Registration is FREE
|
|
|
|
12-27-2008, 09:47 AM
|
Re: PHP sort content by date
|
Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
|
I don't see what you mean and now I don't even see what you want anymore.
Maybe you should give an example?
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
|
|
|
|
12-27-2008, 01:07 PM
|
Re: PHP sort content by date
|
Posts: 90
|
so if you go to http://xuroq.co.uk you see all the examples. I want to be able to sort them into categories, one being date. If you click on the preview of one of the examples it shows you the date added. This is the date I want to use to sort the examples on the homepage
__________________
Free Flash designs and tutorials at Please login or register to view this content. Registration is FREE
Shorten your URL's with Please login or register to view this content. Registration is FREE
|
|
|
|
01-02-2009, 11:45 AM
|
Re: PHP sort content by date
|
Posts: 132
Name: Will Anderson
Location: Terre Haute, IN
|
I wonder if using a database would be your easiest bet here.
By using the SQL "ORDER BY" command you can choose to sort your stuff by name, date, popularity, really whatever you have data for
for an introduction to PHP/MySQL see http://us3.php.net/mysql
Hope this helps
|
|
|
|
01-02-2009, 03:01 PM
|
Re: PHP sort content by date
|
Posts: 90
|
I agree that using a database would be the easiest way, but unfortunately my hosting package did not include and databases
__________________
Free Flash designs and tutorials at Please login or register to view this content. Registration is FREE
Shorten your URL's with Please login or register to view this content. Registration is FREE
|
|
|
|
01-02-2009, 04:16 PM
|
Re: PHP sort content by date
|
Posts: 132
Name: Will Anderson
Location: Terre Haute, IN
|
well...
maybe you should find a better hosting package 
I know of a couple free hosting packages that include database access, plus if you want to shell out a couple bucks you can get a whole lot more.
|
|
|
|
|
« Reply to PHP sort content by date
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|