SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Idaho, USA
    0 Post(s)
    0 Thread(s)

    Getting Date Greater Than Chosen Date

    My mind is in a freeze, and I can't figure it out!

    Here's what I have:


    users- Table with username/passwords, etc;
    Data1- Table with user Posts
    Data2- Table with user Posts

    I want to have a contest of who posts the most in the two tables from Date1 - Date2. I can't seem to figure the logistics of this. Her'es what I have in a nut shell:

    $t = "";
    $sql = "SELECT * FROM users";
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result)){
    $username = $row['username'];
    $sql1= "SELECT FROM Data1, Data2 WHERE Date > 2001-05-01 AND username='$username'"
    $result1 = mysql_query($sql1);
    $posts = mysql_num_rows($result);
    $t[$username] = "$posts";
    // somehow sort out $t

    $i = "0";
    foreach($t as $username=>$posts){
    if($i < 11){
    echo("<b>$username</b> Has <b>$posts<b> Posts!");

    My major lack is how to sort these? And will this idea work?

    Thank you for all of your help!

    Alex Stanton
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    0 Post(s)
    0 Thread(s)

    A bubble sort compares successive array elements and switches them if they are not in the proper order. You would compare element 0 with 1, 1 with 2, 2 with 3 etc. When no switches are necessary the array will be sorted. Or, you can use one of many standard sorting functions for arrays: go to and look up "arrays".


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts