Skip to content

Commit

Permalink
homework 2 pre
Browse files Browse the repository at this point in the history
pre funk
  • Loading branch information
paleomedia committed Apr 6, 2015
1 parent b1a7e85 commit 46f4a52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function getComments () {
return $conn->query("SELECT * FROM comments");
}

public function saveJson ($data) {
/* public function saveJson ($data) {
$conn = $this->getConnection();
foreach ($data as $item) {
$saveQuery = "INSERT INTO lawmakers
Expand All @@ -42,6 +42,6 @@ public function saveJson ($data) {
$q->bindParam(":item", $item);
$q->execute();
}

*/

} // end Dao
21 changes: 15 additions & 6 deletions lawmakers.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
$thisPage="Lawmakers";
include 'top.php';
require_once "Dao.php"; ?>
// require_once "Dao.php"; ?>

<div class="maincontainer">

Expand All @@ -14,7 +14,15 @@
//convert json object to php associative array
$data = json_decode($jsondata, true);

/* get the legislator details
/* foreach ($data as $section => $jsons) {
foreach ($jsons as $key => $value) {
echo "<pre>";
echo "$section:\t$key:\t($value)<br>";
echo "</pre>";
}
echo "<br />" }
get the legislator details
// FIXXXXXX extra fields
$suffix = $data['personal']['address']['streetaddress'];
$nickname = $data['personal']['address']['city'];
Expand All @@ -28,8 +36,9 @@
$active = $data['active'];
$chamber = $data['chamber'];
$photo_url = $data['photo_url'];
*/

$db = new PDO("mysql:host=127.0.0.1;port=8889;dbname=idleg_test", "root", "root");
$sql = "INSERT INTO lawmakers(first_name, last_name, middle_name, district, party, active, chamber, photo_url)
VALUES('$first_name', '$last_name', '$middle_name', '$district', '$party', '$active', '$chamber', '$photo_url')";
if(!mysql_query($sql,$con))
Expand All @@ -39,9 +48,9 @@
}

VALUES('".$item['first_name']."', '".$item['last_name']."', '".$item['middle_name']."', '".$item['district']."', '".$item['party']."', '".$item['active']."', '".$item['chamber']."', '".$item['photo_url']."');
*/
try {
/* try {
$dao = new Dao();
} catch (Exception $e) {
var_dump($e);
Expand All @@ -51,6 +60,6 @@
//insert into mysql table
saveJson($data);


*/

include 'footer.php'; ?>

0 comments on commit 46f4a52

Please sign in to comment.