Jump to content

session arrays...


mkosmosports

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/37242-session-arrays/
Share on other sites

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"]
);
}

Link to comment
https://forums.phpfreaks.com/topic/37242-session-arrays/#findComment-177930
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.