Activity Stream
48,167 MEMBERS
6832 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 7 of 7
  1.     
    #1
    Member
    Website's:
    maxneeds.info

    Default jquery advanced sorting question

    Hi !
    I am having problem doing this in php thats why my last hope is jquery.

    Ok here's the problem :
    I need to sort everything based on numbers.
    I am amateur in Jquery so please give some script.

    CURRENT:
    Code: 
    <div id=incase>
    <span class=top_ten_fav id=0>something(has numbers) (<span class=0>2</span>).</span><br />
    <span class=top_ten_fav id=1>something(has numbers) (<span class=1>1</span>).</span><br />
    <span class=top_ten_fav id=2>something(has numbers) (<span class=2>1</span>).</span><br />
    <span class=top_ten_fav id=3>something(has numbers) (<span class=3>1</span>).</span><br />
    <span class=top_ten_fav id=4>something(has numbers) (<span class=4>1</span>).</span><br />
    <span class=top_ten_fav id=5>something(has numbers) (<span class=5>1</span>).</span><br />
    <span class=top_ten_fav id=6>something(has numbers) (<span class=6>1</span>).</span><br />
    <span class=top_ten_fav id=7>something(has numbers) (<span class=7>1</span>).</span><br />
    <span class=top_ten_fav id=8>something(has numbers) (<span class=8>1</span>).</span><br />
    <span class=top_ten_fav id=9>something(has numbers) (<span class=9>14</span>).</span><br />
    <span class=top_ten_fav id=10>something(has numbers) (<span class=10>28</span>).</span><br />
    <span class=top_ten_fav id=11>something(has numbers) (<span class=11>15</span>).</span><br />
    <span class=top_ten_fav id=12>something(has numbers) (<span class=12>1</span>).</span><br /></div>
    
    AND MORE...
    OUTPUT NEEDED :
    Code: 
    something(has numbers) (28).
    something(has numbers) (15).
    something(has numbers) (14).
    something(has numbers) (2).
    something(has numbers) (1).
    something(has numbers) (1).
    something(has numbers) (1).
    something(has numbers) (1).
    something(has numbers) (1).
    something(has numbers) (1).
    Classes and Ids are all editable(i just gave numbers to them so they can help?).

    Pls help that's damn important (i lost 12 hours on pc about this)
    Porsche_maniak Reviewed by Porsche_maniak on . jquery advanced sorting question Hi ! I am having problem doing this in php thats why my last hope is jquery. Ok here's the problem : I need to sort everything based on numbers. I am amateur in Jquery so please give some script. CURRENT: <div id=incase> <span class=top_ten_fav id=0>something(has numbers) (<span class=0>2</span>).</span><br /> Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    If you want it done in php is the something a constant or each something is different?

  4.     
    #3
    Member
    Website's:
    maxneeds.info
    each something is different

    here's the php code !

    PHP Code: 

    function directoryToArray($directory$recursive) {
        
    $array_items = array();
        if (
    $handle opendir($directory)) {
            while (
    false !== ($file readdir($handle))) {
                if (
    $file != "." && $file != "..") {
                    if (
    is_dir($directory"/" $file)) {
                        if(
    $recursive) {
                            
    $array_items array_merge($array_itemsdirectoryToArray($directory"/" $file$recursive));
                        }
                        
    $file $directory "/" $file;
                        
    $array_items[] = preg_replace("/\/\//si""/"$file);
                    } else {
                        
    $file $directory "/" $file;
                        
    $array_items[] = preg_replace("/\/\//si""/"$file);
                    }
                }
            }
            
    closedir($handle);
        }
        return 
    $array_items;
    }

    $filenamesdl=directoryToArray('fav',true);

    $filenames = array();
    while (list (
    $key$val) = each ($filenamesdl)) { 
    if(
    strstr($val,".txt")){
    $filenames[]=basename($val); }
    }

    $filenames=array_count_values($filenames);


    $total = array();
    while (list (
    $key2$val2) = each ($filenames)) { 
    $total[]=$val2;
    }


    $i=0;
    foreach (
    $filenamesdl as $dl) {
    $filenamesdl=@file_get_contents($dl);
    if(!empty(
    $filenamesdl) && !empty($total[$i])){
    $entry_arrayz'entry' ]  .=  '<span class=top_ten_fav id='.$i.'>'.$filenamesdl '(<span class='.$i.'>'.$total[$i].'</span>).</span><br />';
         
    $i++;
         } }
    $entry_arrayz'entry' ]="<div id=incase>".$entry_arrayz'entry' ].'</div>'
    The php script downloads all .txt files in a directory (+subdirs) and counts the filenames(array_count_values).
    So i must sort the downloaded txt with the array_count_values.

  5.     
    #4
    (╯?□?)╯︵ ┻━┻
    Website's:
    Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.com
    http://jsfiddle.net/NFfw4/

    this seems to work, i expected it to duplicate the divs when running the each() loop but it didn't, which is good lol.
    Projects:
    WCDDL - The Professional DDL Script
    Top Secret Project: In Development - ZOMG
    ImgTrack - Never Have Dead Images Again!

  6.     
    #5
    Member
    Website's:
    maxneeds.info
    @JmZ
    woow man ! You just discovered new jquery function which i bet many people will use ! It is equal to natsort in php ! So many tnx ! I wish i had a paypal to pay you a beer

    Btw how to limit the results to ten ?

  7.     
    #6
    (╯?□?)╯︵ ┻━┻
    Website's:
    Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.com
    Projects:
    WCDDL - The Professional DDL Script
    Top Secret Project: In Development - ZOMG
    ImgTrack - Never Have Dead Images Again!

  8.     
    #7
    Member
    Website's:
    maxneeds.info

    Finally. I feel bit relaxed cuz the only thing left to do is to make delete/edit functions to my custom forum

    JQuery is so powerful and it has future !
    TNX !

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sorting links but with something more..
    By stefan-te in forum Technical Help Desk Support
    Replies: 4
    Last Post: 1st Aug 2012, 10:11 PM
  2. JQuery and RegExr Help :|
    By Porsche_maniak in forum Web Development Area
    Replies: 4
    Last Post: 1st Jun 2012, 12:26 AM
  3. JQuery help
    By xElliex in forum Web Development Area
    Replies: 5
    Last Post: 25th Aug 2011, 10:38 PM
  4. Help sorting files from directory by latest uploaded
    By Jgutz in forum Webmaster Discussion
    Replies: 1
    Last Post: 29th Mar 2011, 07:53 PM
  5. Default Sorting Categories?
    By Golden Falcon in forum phpBB
    Replies: 0
    Last Post: 24th Sep 2008, 11:24 PM

Tags for this Thread

BE SOCIAL