mkosmosports Posted February 6, 2007 Share Posted February 6, 2007 Hey, Ive got the following loop which loads a whole bunch of data from a query into an array. while ( $row = mysql_fetch_array($alltransfers, MYSQL_ASSOC) ) { $alltrarr[] = array('id' => $row["ID"], 'date' => $row["DATE_FORMAT(TP.START_DATE,'%m')"], 'pos' => $row["CODE"], 'nickname' => $row["NICK_NAME"], 'fullname' => $row["FULL_NAME"], 'toteam' => $row["QUICK_NAMEto"], 'fromteam' => $row["QUICK_NAMEfrom"], 'status' => $row["STATE"], 'sum' => $row["TRANSFER_SUM"]); } Then, I load that array into the session. $_SESSION['trdata'] = $alltrarr; Is there a way I can have the loop load the query data directly into the session array, so I dont have to essentially create two arrays, like in the above case "$alltrarr" and $_SESSION['trdata']? Thanks Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted February 6, 2007 Share Posted February 6, 2007 what's wrong with doing something like while ( $row = mysql_fetch_array($alltransfers, MYSQL_ASSOC) ) { $_SESSION['trdata'][] = array('id' => $row["ID"], 'date' => $row["DATE_FORMAT(TP.START_DATE,'%m')"], 'pos' => $row["CODE"], 'nickname' => $row["NICK_NAME"], 'fullname' => $row["FULL_NAME"], 'toteam' => $row["QUICK_NAMEto"], 'fromteam' => $row["QUICK_NAMEfrom"], 'status' => $row["STATE"], 'sum' => $row["TRANSFER_SUM"]); } or spaced for sanity (same as above just without the eye bleeding) while ( $row = mysql_fetch_array($alltransfers, MYSQL_ASSOC) ) { $_SESSION['trdata'][] = array( 'id' => $row["ID"], 'date' => $row["DATE_FORMAT(TP.START_DATE,'%m')"], 'pos' => $row["CODE"], 'nickname' => $row["NICK_NAME"], 'fullname' => $row["FULL_NAME"], 'toteam' => $row["QUICK_NAMEto"], 'fromteam' => $row["QUICK_NAMEfrom"], 'status' => $row["STATE"], 'sum' => $row["TRANSFER_SUM"] ); } Quote Link to comment Share on other sites More sharing options...
mkosmosports Posted February 6, 2007 Author Share Posted February 6, 2007 Hey, Ive tried this before, however it puts everything in another array, and this produces unexpected results later on..... Quote Link to comment 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.