aeroswat Posted January 22, 2010 Share Posted January 22, 2010 Is it possible to do something like this $arr[1] = mysql_fetch_array($result); $_SESSION['arrays']=$arr; echo $_SESSION['arrays'][1]['field]; ? I want to store all of the arrays from a result set into an array of arrays and then store that array of arrays in a session array O_o Quote Link to comment https://forums.phpfreaks.com/topic/189487-mysql_fetch_array-into-array/ Share on other sites More sharing options...
premiso Posted January 22, 2010 Share Posted January 22, 2010 $_SESSION['arrays'] = array(); while ($row = mysql_fetch_assoc($result)) { $_SESSION['arrays'][] = $row; } echo "<pre>", print_r($_SESSION['arrays'], true), "</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/189487-mysql_fetch_array-into-array/#findComment-1000186 Share on other sites More sharing options...
aeroswat Posted January 27, 2010 Author Share Posted January 27, 2010 $_SESSION['arrays'] = array(); while ($row = mysql_fetch_assoc($result)) { $_SESSION['arrays'][] = $row; } echo "<pre>", print_r($_SESSION['arrays'], true), "</pre>"; Can you access that array by index and field? like this $_SESSION['arrays'][0]['fieldName'] $_SESSION['arrays'][1]['fieldName'] $_SESSION['arrays'][0]['fieldName2'] etc Quote Link to comment https://forums.phpfreaks.com/topic/189487-mysql_fetch_array-into-array/#findComment-1002414 Share on other sites More sharing options...
premiso Posted January 27, 2010 Share Posted January 27, 2010 You can try it out yourself and see if you can. Quote Link to comment https://forums.phpfreaks.com/topic/189487-mysql_fetch_array-into-array/#findComment-1002431 Share on other sites More sharing options...
aeroswat Posted January 27, 2010 Author Share Posted January 27, 2010 You can try it out yourself and see if you can. K just didn't want to break anything Quote Link to comment https://forums.phpfreaks.com/topic/189487-mysql_fetch_array-into-array/#findComment-1002452 Share on other sites More sharing options...
aeroswat Posted January 27, 2010 Author Share Posted January 27, 2010 It worked exactly like I wanted it to. Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/189487-mysql_fetch_array-into-array/#findComment-1002604 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.