currently I have two pieces of data being stored in a sql db and then pulled into my website. What I want though is the two pieces of data being stored to be separated instead of totaled together.
So i setup my DB like so:
DROP TABLE IF EXISTS totals;
CREATE TABLE totals (
id int(11) NOT NULL AUTO_INCREMENT,
total float NOT NULL,
PRIMARY KEY (id)
) ;
INSERT INTO totals VALUES (1, 0);
And the PHP I'm using:
$api = array();
$api[] = 'http://api.jo.je/justgiving/data/myuserpage';
$api[] = 'http://api.jo.je/justgiving/data/myuserpage2';
$total = 0;
foreach($api as $data) {
$open = file_get_contents($data);
$feed = json_decode($open);
if(is_object($feed)) {
$total = $total + $feed->donations_total;
}
}
// database connection
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass); // new data
$id = 1;
// query
$sql = "SELECT total
from totals
WHERE id=?";
$q = $conn->prepare($sql);
$q->execute(array($id));
$data = $q->fetch();
$total = $data['total'];
Being a noobie at this, I just need some help storing two seperate pieces of data instead of one.