Aeolus Posted August 20, 2009 Share Posted August 20, 2009 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). Quote Link to comment https://forums.phpfreaks.com/topic/171158-so-i-know-i-can-do-this/ Share on other sites More sharing options...
Bricktop Posted August 20, 2009 Share Posted August 20, 2009 Edit. Quote Link to comment https://forums.phpfreaks.com/topic/171158-so-i-know-i-can-do-this/#findComment-902579 Share on other sites More sharing options...
Maq Posted August 20, 2009 Share Posted August 20, 2009 Looks like you're looping correctly. Are you sure your query is supposed to return more than 1 record? Quote Link to comment https://forums.phpfreaks.com/topic/171158-so-i-know-i-can-do-this/#findComment-902582 Share on other sites More sharing options...
Aeolus Posted August 20, 2009 Author Share Posted August 20, 2009 Should I just replace my while with foreach? That returns an error unexpected ')' Quote Link to comment https://forums.phpfreaks.com/topic/171158-so-i-know-i-can-do-this/#findComment-902584 Share on other sites More sharing options...
Maq Posted August 20, 2009 Share Posted August 20, 2009 Should I just replace my while with foreach? That returns an error unexpected ')' No. Quote Link to comment https://forums.phpfreaks.com/topic/171158-so-i-know-i-can-do-this/#findComment-902586 Share on other sites More sharing options...
Aeolus Posted August 20, 2009 Author Share Posted August 20, 2009 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) { Quote Link to comment https://forums.phpfreaks.com/topic/171158-so-i-know-i-can-do-this/#findComment-902589 Share on other sites More sharing options...
Bricktop Posted August 20, 2009 Share Posted August 20, 2009 Hi Aeolus, Is this query definitely correct? $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"); Quote Link to comment https://forums.phpfreaks.com/topic/171158-so-i-know-i-can-do-this/#findComment-902591 Share on other sites More sharing options...
Aeolus Posted August 20, 2009 Author Share Posted August 20, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/171158-so-i-know-i-can-do-this/#findComment-902600 Share on other sites More sharing options...
Maq Posted August 20, 2009 Share Posted August 20, 2009 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); Quote Link to comment https://forums.phpfreaks.com/topic/171158-so-i-know-i-can-do-this/#findComment-902618 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.