Php 选择WHERE语句

Php 选择WHERE语句,php,ionic-framework,Php,Ionic Framework,我正在尝试从数据库中选择a值,例如 $stmt = $pdo->query('SELECT acc_id FROM account_info WHERE acc_id = (the most recent value entered '); 我试过: $stmt = $pdo->query('SELECT acc_id FROM account_info WHERE acc_id = "26" '); 这是成功的。但是,每当我尝试以下方法时: $stmt = $pdo->

我正在尝试从数据库中选择a值,例如

 $stmt = $pdo->query('SELECT acc_id FROM account_info WHERE acc_id = (the most recent value entered ');
我试过:

$stmt = $pdo->query('SELECT acc_id FROM account_info WHERE acc_id = "26" '); 
这是成功的。但是,每当我尝试以下方法时:

$stmt = $pdo->query('SELECT acc_id FROM account_info WHERE acc_id = :acc_id');

我得到以下错误:

core.js:1350 ERROR SyntaxError: Unexpected token S in JSON at position 0
at JSON.parse (<anonymous>)
这是我的HTML:

<ion-item *ngFor="let item of items">
<h2>{{ item.acc_id }} </h2>
<button ion-button color="primary" item-right (click)="viewEntry({ account: item })">View</button>
 </ion-item>

{{item.acc_id}
看法
我做错了什么?我怎样才能修好它??
提前谢谢你

如果要创建并执行一条准备好的语句,需要先准备查询,绑定参数,然后执行

$stmt = $pdo->prepare('SELECT acc_id FROM account_info WHERE acc_id = :acc_id');
$stmt->execute([':acc_id' => 26]);
$result = $stmt->fetchAll();

按acc\u id DESC LIMIT 1从账户信息订单中选择acc\u id

按acc\u id DESC LIMIT 1从账户信息订单中选择acc\u id
感谢您的回复!我试过了,它返回的值不是应该返回的值,而是
http://localhost:10080/ionic/patients.php
因为我们不知道它应该在哪里返回值,很难再进一步帮助您我很抱歉我更新了我的问题我们无法访问您的本地主机
从帐户信息中选择acc\u id按acc\u id DESC LIMIT 1执行命令,但显示了值
<ion-item *ngFor="let item of items">
<h2>{{ item.acc_id }} </h2>
<button ion-button color="primary" item-right (click)="viewEntry({ account: item })">View</button>
 </ion-item>
$stmt = $pdo->prepare('SELECT acc_id FROM account_info WHERE acc_id = :acc_id');
$stmt->execute([':acc_id' => 26]);
$result = $stmt->fetchAll();