php - Get sql to return correct post -



php - Get sql to return correct post -

im trying sql query homecoming post in db id.

my table looks this:

id|img|desc|date

and want homecoming single post depending in id gets passed. im using pdo. , homecoming posts this:

function getuser($id) { echo $id; //i want post has id. } function getprojects() { $sql = "select * projects"; seek { $db = getconnection(); $stmt = $db->query($sql); $users = $stmt->fetchall(pdo::fetch_obj); $db = null; echo json_encode($users); } catch(pdoexception $e) { echo json_encode($e->getmessage()); } }

you forgot where clause.

$sql = "select * projects id = " . $whateveridyouwant;

php mysql pdo

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -