I have an very nasty issue....
My usage for this code: I wanna get through AJAX, just 5 records everytime i click on the further-button. I´m not so far yet....
This script just have to get me 5 records from a specific user.
The Problem:
So the sql queries run without any problems on the Database. But when i wanna do it in PHP-script, i get ONLY from the first query the counter() AND the second query gives me an empty array from the PDO-Statement.
CODE:
if (empty($_SESSION['counter']) || ($_SESSION['counter'] < 0)) {
$sql = 'SELECT count(record.record_id) AS counter FROM record
LEFT JOIN recordbook ON record.record_id = recordbook.record
WHERE user = ?';
$sth = $this->dbc->prepare($sql);
$sth->execute(array($u_id['user_id']));
$count = $sth->fetch();
$_SESSION['counter'] = $count['counter'];
var_dump($_SESSION);
}
$_SESSION['counter'] = $_SESSION['counter'] - 5;
$sql = 'SELECT record.record_id, status, place, record.record AS records, comment, recorddate
FROM record LEFT JOIN recordbook ON record.record_id = recordbook.record
WHERE user = ? ORDER BY record.record_id DESC LIMIT ?,5';
$sth = $this->dbc->prepare($sql);
$sth->execute(array($u_id['user_id'],
$_SESSION['counter']));
$output = $sth->fetchAll();
}
HOPE someone know how to solve this...
table structure
Field | Type | Null | Key | Default | Extra
record_id | int(10) unsigned | NO | PRI NULL | auto_increment
status | varchar(200) | YES | NULL |
place | varchar(200) | YES | NULL
record | longtext | YES NULL
comment | longtext | YES | NULL
recorddate | timestamp | YES | CURRENT_TIMESTAMP
attachment_id | int(10) unsigned | YES | MUL | NULL