php - Prepared Statements + MySQL (7 day Stats) -


i'm working on project in need store 7 days worth of data each individual object user creates, each object has unique id user. guess more of "how go doing this?" vs. "what doing wrong?". goal keep 7 days worth of stats @ time , able print them out jqplot or other graphing library based on object_id.

enter image description here

my current code grabbing data isn't far along. started using prepared statements , i'm not understanding methods getting results query.

$stmt = $mysql->prepare("select `date`, `impressions`, `clicks`, `object_id` `object_stats` `user_id` = ?") or die(mysql_error()); $stmt->bind_param("s", $_session['user_id']); $stmt->execute(); $stmt->bind_result($date, $impressions, $clicks, $object_id); $stmt->close(); 

from there going put results multi-dimensional array, , have array each object_id, had no idea start, tried googling similar solutions didn't come across anything. apologize if i'm not communicating problem, i'm having hard time putting words. appreciated, thanks.

try using pdo instead, has cool features, fetching data multidimensional arrays simple fetch; you're looking for.

check tutorial out:

http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/

i feel kind today , provide sample code:

$sth = $dbh->prepare('select `object_id`, `date`, `impressions`, `clicks`  `object_stats` `user_id` = ?'); $sth->execute(array($_session['user_id']));  $data = $sth->fetchall(pdo::fetch_column | pdo::fetch_group); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -