Jump to content

Recommended Posts

But right now my mind is a blank slate. Anyone want to jumpstart my battery?

 

    $result = @mysql_query("SELECT * FROM e_result WHERE EXISTS ( SELECT `points` FROM e_pointscale WHERE e_pointscale.c_group=$c_group AND e_pointscale.place = e_result.rank ) and c_id=$c_id ORDER BY rank");
    if( !$result ) { trigger_error( "Failed Connection: " . mysql_error() ); }
    
    while ($row = mysql_fetch_array($result)) {
        
        echo '<tr> <td><b>
        ' . $row ['name'] . '</b></td> <td>';
        printf("%04.1f", $row ['d_score']); echo '</td> <td>';
        printf("%04.1f", $row ['c_score']); echo '</td> <td>';
        printf("%02.0f", $row ['j_score']); echo '</td> <td>';
        echo $row ['score'] . '</td> <td>';
        echo $row ['count'] . '</td> <td>
        ' . $row ['rank'] . ' </td> <td>';
        echo $row ['points'] . '</td></tr>';
        };

 

it's only returning one row, instead of looping to repeat for each row found. I know it's a simple fix, I'm doing something wrong with requesting my information (trying to get points from points table for each row on the e_results table).

Link to comment
https://forums.phpfreaks.com/topic/171158-so-i-know-i-can-do-this/
Share on other sites

Now it's returning way too many... looks like it's just returning all the rows off the points table... maybe I should try this a different way.. :/

 

        $rowi = mysql_fetch_array($result);
            
            foreach ($rowi as &$row)    {

No, that's what I'm questioning. I'll play around with it and update this posting this afternoon with what I find - for now I have to go feed horses!

 

It's hard for us to help with that sort of query and not even knowing what you want.  You can echo out your query to ensure it's what you intend:

 

$sql = "SELECT * FROM e_result WHERE EXISTS ( SELECT `points` FROM e_pointscale WHERE e_pointscale.c_group=$c_group AND e_pointscale.place = e_result.rank ) and c_id=$c_id ORDER BY rank";
echo "QUERY=> " . $sql;
$result = mysql_query($sql);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.