jmaccs64 Posted April 6, 2011 Share Posted April 6, 2011 Can someone please tell me the right way to do this? $q = "SELECT * FROM scores WHERE student_id = {$student_id} ORDER BY test_type ASC"; $r = mysql_query($q) or die(); $r2 = mysql_fetch_array($r); $data[$r2['student_id']] = array( 'last_name' => $r2['last_name'], 'first_name' => $r2['first_name'], 'grad_year' => $r2['grad_year'] ); mysql_data_seek($r, 0); while($row=mysql_fetch_assoc($r)) { $data[testName($row['test_type'])] = array( 'eng' => $row['eng'], 'math' => $row['math'], 'read' => $row['read'], 'sci' => $row['sci'], 'comp' => round(($row['eng'] + $row['math'] + $row['read'] + $row['sci'])/4 ) ); } My Database Structure - All the different test-scores are in the same table, labeled with the test type &test-id.. id-student_id-last_name-first_name-eng-math-read-sci-grad_year-test_id-test_type 1-99999-smith-john-12-12-12-12-2012-1-3 I hope this makes sense! Thanks-In-Advance Link to comment https://forums.phpfreaks.com/topic/232920-refactor-multidimensional-disaster/ Share on other sites More sharing options...
btherl Posted April 6, 2011 Share Posted April 6, 2011 Is that the right way to do what? Link to comment https://forums.phpfreaks.com/topic/232920-refactor-multidimensional-disaster/#findComment-1197967 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.