Storing data in multiple sessions
Hi what I'm trying to do is put all 5 of the file id's into sessions so I can later move the according physical file names. the $sid sessionID will be the same for each, the query pulls the unique $data[Id]. The limit is set to 5, how do I make sure each session gets a unique data[Id] from the results and if there is only 3 result don't use the last 2...
$results = mysql_query("SELECT * FROM test WHERE Language = '".$lang."' ORDER BY id DESC, CreationDate DESC LIMIT $start, 5");
while ($data = mysql_fetch_ar开发者_JAVA技巧ray($results)) {
$Record_Count = $Record_Count + 1;
session_start();
$sid = session_id();
unset($_SESSION['file_1'], $file_1);
$_SESSION['file_1'] = $sid . '-' . $data[Id] . '-slow';
unset($_SESSION['file_2'], $file_2);
$_SESSION['file_2'] = $sid . '-' . $data[Id] . '-slow';
unset($_SESSION['file_3'], $file_3);
$_SESSION['file_3'] = $sid . '-' . $data[Id] . '-slow';
unset($_SESSION['file_4'], $file_4);
$_SESSION['file_4'] = $sid . '-' . $data[Id] . '-slow';
unset($_SESSION['file_5'], $file_5);
$_SESSION['file_5'] = $sid . '-' . $data[Id] . '-slow';
}
You can only have one session running at a time.
To make sure there's only three results, put the collected IDs in an array and test its length.
if(count($collectedIDs) != 3) { $collectedIDs[] = $newID; }
use 2 dimension array like : $_SESSION['files'][]
session_start();
$sid = session_id();
unset($_SESSION['files']);
$Record_Count = 0;
while ($data = mysql_fetch_array($results) && $Record_Count < 5) {
$Record_Count = $Record_Count + 1;
$_SESSION['files'][] = $sid . '-' . $data[Id] . '-slow';
}
精彩评论