Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP sort content by date
Old 12-22-2008, 12:57 PM PHP sort content by date
Skilled Talker

Posts: 90
Trades: 0
I believe there is a way to sort content by date. At the moment I have the array
PHP Code:
=> "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",
=> "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
xuroq is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-22-2008, 03:54 PM Re: PHP sort content by date
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
PHP Code:
$array = array(=> "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",
=> "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++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 12-22-2008, 04:00 PM Re: PHP sort content by date
Skilled Talker

Posts: 90
Trades: 0
is there no easier way to just get php to sort dates. attached is my file of what i have so far
Attached Files
File Type: zip preview.zip (1.2 KB, 2 views)
__________________
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..
xuroq is offline
Reply With Quote
View Public Profile
 
Old 12-25-2008, 05:19 PM Re: PHP sort content by date
Skilled Talker

Posts: 90
Trades: 0
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
xuroq is offline
Reply With Quote
View Public Profile
 
Old 12-25-2008, 07:57 PM Re: PHP sort content by date
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
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.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 12-26-2008, 04:23 AM Re: PHP sort content by date
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
Have you actually tried the code I posted?
Because I think it works...
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 12-27-2008, 09:36 AM Re: PHP sort content by date
Skilled Talker

Posts: 90
Trades: 0
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
xuroq is offline
Reply With Quote
View Public Profile
 
Old 12-27-2008, 09:47 AM Re: PHP sort content by date
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
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++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 12-27-2008, 01:07 PM Re: PHP sort content by date
Skilled Talker

Posts: 90
Trades: 0
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
xuroq is offline
Reply With Quote
View Public Profile
 
Old 01-02-2009, 11:45 AM Re: PHP sort content by date
anderswc's Avatar
Super Talker

Posts: 132
Name: Will Anderson
Location: Terre Haute, IN
Trades: 0
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
__________________
Will Anderson

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
anderswc is offline
Reply With Quote
View Public Profile Visit anderswc's homepage!
 
Old 01-02-2009, 03:01 PM Re: PHP sort content by date
Skilled Talker

Posts: 90
Trades: 0
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
xuroq is offline
Reply With Quote
View Public Profile
 
Old 01-02-2009, 04:16 PM Re: PHP sort content by date
anderswc's Avatar
Super Talker

Posts: 132
Name: Will Anderson
Location: Terre Haute, IN
Trades: 0
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.
__________________
Will Anderson

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
anderswc is offline
Reply With Quote
View Public Profile Visit anderswc's homepage!
 
Reply     « Reply to PHP sort content by date
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.64670 seconds with 13 queries