I am using Angular to create my single page views but I am struggling to pass an ID from an sql select via the URL.
I have created my view like so:
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/jobSingle", {
templateUrl : "jobSingle.php"
});
});
Works great shows me the correct page. I am TESTING data so this is open to SQL injection but I am playing around with Angular so don't freak out - I am linking to the single view page from another view like so:
$sql = "SELECT * FROM jobs";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) { // Start while
echo $row['title'];
echo '<a href="#jobSingle?id=' . $row['id'] . '">View Job</a>';
?>
<div class="lightboxHide animated fadeInUp">
<div id="mylightbox">
<?php echo $row['title']; ?>
</div>
</div>
<?php
} // End while
} else {
echo "0 results";
}
So where I have echo '<a href="#jobSingle?id=' . $row['id'] . '">View Job</a>';
it appears to be the correct url and it opens the correct view but when I GET the id form the URL and var dump it i get nothing...
$jobId = $_GET['id'];
var_dump($_GET);
$sql = "SELECT * FROM jobs WHERE id = '$jobId'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) { // Start while
echo $row['title'];
} // End while
} else {
echo "0 results";
}
My var dump just simply shows....
array(0) { } 0 results
Aswell when I do a var_dump on the $_GET
I get a NULL
value returned... Its almost like the url is being ignore, well the Id is at least...
Is this even possible OR am I missing the point here? I am learning angular as I work with Php primarily I wanted to know if this was do able?