I am trying to read out a database row by id but it is not passing my (isset) if statement. I know the fetch all funtion works as I can var_dump the data but when I run it through the (fetch data)function. No data comes through. What am I missing?
class Article {
public function fetch_all(){
global $pdo;
$query= $pdo->prepare("SELECT * FROM article");
$query->execute();
return $query->fetchAll();
}
public function fetch_data($article_id)
{
global $pdo;
$query = $pdo->prepare("SELECT * FROM article WHERE article_id =?");
$query->bindValue(1, $article_id);
$query->execute();
return $query->fetch();
}
}
then I am calling on another page -
include_once('includes/connection.php');
include_once('includes/article.php');
///$article = new Article;
//$articles = $article->fetch_data();
///var_dump($article);
if (isset($_GET['id'])){
$id = $_GET['id'];
$data = $article->fetch_data($id);
The new Article call works but its never getting the ID to pass. Any help would be amazing. I need this for my final tomorrow.
Thank You,
Devin