我的php更新代码有什么问题?

I'm making a php update system for my friend and i don't know how to fix this error I keep getting.

It says that the error is in the page where I have my class in.

Notice: Undefined index: post_id in C:\Apache24\htdocs\home\includes\editpost.php on line 6

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1' in C:\Apache24\htdocs\home\includes\editpost.php:7 Stack trace: #0 C:\Apache24\htdocs\home\includes\editpost.php(7): PDOStatement->execute() #1 C:\Apache24\htdocs\home\edit.php(7): Article->fetch_all() #2 {main} thrown in C:\Apache24\htdocs\home\includes\editpost.php on line 7

Here is my class code.

class Article{
public function fetch_all() {
global $conn;
$query = $conn->prepare("SELECT * FROM news WHERE post_id = $_GET[post_id]");
$query->execute();

return $query->fetchAll();


}

} I will upload any other code that you would need to help me thank your for your time.

Note that your function needs the value $_GET[post_id]

Your script need to pass the the value in the URL requested for example, the user would to call a URL link http://yoursite.com/list.php?post_id=10

and your page list.php would include and use your Article class and call the method fetch_all to make the query yoy want. Take care with the use of global variables to store your database connection and i would suggest you to make post_id a parameter of fetch_all function.