Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Sorting data display

  1. #11
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yeah it's still giving me trouble.

    PHP Code:
    <?php
    $username
    ="";
    $password="";
    $database="";

    mysql_connect(localhost,$username,$password);
    mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM showdates ORDER BY date DESC";
    $info=mysql_query($query);

    $num=mysql_numrows($info);

    $sql "SELECT date FROM showdates where date > (select curdate())";

    $result mysql_query($sql);

    $i=0;
    while (
    $i $num) {

    $date=mysql_result($result,$i,"date");
    $venue=mysql_result($result,$i,"venue");
    $location=mysql_result($result,$i,"location");
    $information=mysql_result($result,$i,"information");
    while(
    $record mysql_fetch_object($res))
    {
    echo 
    "<tr><td>$date</td><td>$venue</td><td>$location</td><td>$information</td></tr>";
    }
    $i++;
    }

    mysql_close();
    ?>
    and here is the exact error message:

    Warning: mysql_result() [function.mysql-result]: venue not found in MySQL result index 4 in /home/kc/public_html/shows2.php on line 75

    Warning: mysql_result() [function.mysql-result]: location not found in MySQL result index 4 in /home/kc/public_html/shows2.php on line 76

    Warning: mysql_result() [function.mysql-result]: information not found in MySQL result index 4 in /home/kc/public_html/shows2.php on line 77

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/kc/public_html/shows2.php on line 78

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 74

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 75

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 76

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 77

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/kc/public_html/shows2.php on line 78

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 74

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 75

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 76

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 77

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/kc/public_html/shows2.php on line 78

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 3 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 74

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 3 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 75

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 3 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 76

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 3 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 77

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/kc/public_html/shows2.php on line 78

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 4 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 74

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 4 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 75

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 4 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 76

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 4 on MySQL result index 4 in /home/kc/public_html/shows2.php on line 77

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/kc/public_html/shows2.php on line 78

  2. #12
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Ok, try this in your query:

    Code:
    $sql = "SELECT * FROM showdates where date > (select curdate())";
    Hope this helps.

    //Added Later: Also, be sure to change the names in this part (the ones in red) to match your database:

    Code:
    $date=mysql_result($result,$i,"date");
    $venue=mysql_result($result,$i,"venue");
    $location=mysql_result($result,$i,"location");
    $information=mysql_result($result,$i,"information");
    Last edited by thetestingsite; 04-11-2007 at 04:32 PM.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #13
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I moved some things around and did your suggestions which got rid of all those error messages except now theres a new one:

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/kc/public_html/shows2.php on line 75
    PHP Code:
    <?php
    $username
    ="";
    $password="";
    $database="";

    mysql_connect(localhost,$username,$password);
    mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM showdates ORDER BY date DESC";
    $info=mysql_query($query);

    $num=mysql_numrows($info);

    $sql "SELECT * FROM showdates where date > (select curdate())";

    $result mysql_query($sql);

    $date=mysql_result($result,$i,"date");
    $venue=mysql_result($result,$i,"venue");
    $location=mysql_result($result,$i,"location");
    $information=mysql_result($result,$i,"information");
    while(
    $record mysql_fetch_object($res))
    {

    $i=0;
    while (
    $i $num) {

    echo 
    "<tr><td>$date</td><td>$venue</td><td>$location</td><td>$information</td></tr>";
    }
    $i++;
    }

    mysql_close();
    ?>

  4. #14
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    That is due to this line:

    Code:
    while($record = mysql_fetch_object($res))
    The part in red should be $result

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #15
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    is there something in the code that tells it to repeat? for some reason i wrote a test entry and it only showed that future entry but it repeated it hundreds of times and actually froze the browser.

  6. #16
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    That would be due to a bad (endless) loop. The only thing that I see that could cause this would be this line:

    Code:
    $num=mysql_numrows($info);
    It should be:

    Code:
    $num=mysql_num_rows($info);
    Other than that, the script should work fine. Sorry I didn't notice that before.
    Anyways, hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #17
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    The while loop in this case, never ends, considering it fetches data from the server continuosly. So you can call the variables inside the loop when you want.
    If you tried echo inside the loop, naturally, it would freeze up.
    mysql_fetch_obj never returns true so the loop is infinite.
    - Mike

  8. #18
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Instead of fumbling through this script to make it work, I decided to rewrite the script. Try the following to see if it works for you:

    Code:
    <?php
    $username="";
    $password="";
    $database="";
    
    mysql_connect(localhost,$username,$password);
    mysql_select_db($database) or die( "Unable to select database");
    
    $sql = "SELECT * FROM showdates where date > (select curdate())";
    
    $result = mysql_query($sql);
    
    echo '<table>';
    
     while ($q = mysql_fetch_array($result)) {
    
    echo "<tr><td>".$q['date']."</td><td>".$q['venue']."</td><td>".$q['location']."</td><td>".$q['information']."</td></tr>";
     }
    
    echo '</table>';
    
    mysql_close();
    ?>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

Bookmarks

Posting Permissions

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