physics

msg:3427553 | 4:39 am on Aug 21, 2007 (gmt 0) |
Hi beaudettee and welcome to WebmasterWorld.com! It depends on what you want to do but an example would be:
$values = array(); while ($Row = mySql_fetch_array ($Result)) { $values[ $Row['COUNT(qTimeStamp)'] ] = $Row['qResultClass']; } foreach ( $values as $k => $v ) { print ``$k is the key for $v<br />\n''; } print_r($values);
|
beaudettee

msg:3427747 | 10:47 am on Aug 21, 2007 (gmt 0) |
Thanks for the warm welcome and quick response physics. I am getting closer! I plugged in your solution and for some reason I am missing the first result set. I kept my first echo statement in to compare values as follows: $Query = "SELECT qResultClass, COUNT(qTimeStamp) FROM quiz GROUP BY qResultClass"; $Result = mySql_db_query ($DBname, $Query, $Link); $values = array(); while ($Row = mySql_fetch_array ($Result)) { echo "There are ". $Row['COUNT(qTimeStamp)'] ." ". $Row['qResultClass'] ." items."; echo "<br />"; $values[ $Row['COUNT(qTimeStamp)'] ] = $Row['qResultClass']; } foreach ( $values as $k => $v ) { print $k . "is the key for " . $v . "<br />\n"; } mySql_close ($Link); print_r($values); **************************** and my result is: **************************** There are 3 1 items. There are 3 2 items. There are 1 3 items. There are 2 4 items. 3is the key for 2 1is the key for 3 2is the key for 4 Array ( [3] => 2 [1] => 3 [2] => 4 ) Any ideas? Thanks again for your help! Eric B
|
beaudettee

msg:3428903 | 2:31 pm on Aug 22, 2007 (gmt 0) |
Ok.. So I figured it out. I had to switch my recordset columns around in your solution. That fixed it. Thanks again! $Query = "SELECT qResultClass, COUNT(qTimeStamp) FROM quiz GROUP BY qResultClass"; $Result = mySql_db_query ($DBname, $Query, $Link); $values = array(); while ($Row = mySql_fetch_array ($Result)) { echo "There are ". $Row['COUNT(qTimeStamp)'] ." ". $Row['qResultClass'] ." items."; echo "<br />"; $values[ $Row['qResultClass'] ] = $Row['COUNT(qTimeStamp)']; } foreach ( $values as $k => $v ) { print $k . "is the key for " . $v . "<br />\n"; } mySql_close ($Link); print_r($values);
|
physics

msg:3430889 | 4:55 am on Aug 24, 2007 (gmt 0) |
Hey beaudettee, you're welcome and I'm glad you got the solution working :)
|
|