Hello. Using PHP. How do I put the result of a select into a session and after that read that records for to show in a display??
It depends on how you'd put it in a session variable. It should be something like this: while ($row = mysqli_fetch_array($result)) $watever[] = $row['lol']; $_SESSION['poop'] = $watever; for($i=0; $i < count($_SESSION['poop']); $i++) echo $_SESSION['poop'][$i]; PHP: Also, see this.
$q = mysql_query("SELECT id FROM blah"); $i = 0; while ($res = mysql_fetch_array($q)) { $_session[$i]['id'] = $res['id']; $i++; } PHP: assumes session already set
Duh not. You never mentioned a field in your first post.. Here: while ($row = mysqli_fetch_array($result)) $watever[] = array ( 'id' => $row['id'], 'code' => $row['code'], 'name' => $row['name'], 'date' => $row['date'], 'address' => $row['address'] ); $_SESSION['poop'] = $watever; // this is the general idea! foreach ($_SESSION['poop'] as $yeaa) echo $yeaa['id'] . $yeaa['code'] . $yeaa['name'] . $yeaa['date'] . $yeaa['address']; PHP:
Do you have any idea, how PHP serializes these arrays to put into sessions (which can physically contain nothing but string)?
Not sure, but it should theoretically create a two-dimensional associative array if you do this: $_SESSION['poop'] = $watever; PHP: If so, then this should be possible: <?php session_start( ); $watever['meow'] = "poop"; $_SESSION['lol'] = $watever; echo $_SESSION['lol']['meow']; // something like this ?> PHP: I haven't tested it myself though, but it should be theoretically possible.
those variable names made me chuckle. As the mysql_fetch_array is already an array, this also works session_start(); while ($res = mysql_fetch_array($qid)) { $_SESSION['timmah'] = $res; } echo $_SESSION['timmah']['id']; PHP: