php - How do I count rows in a table according to ID column (prepared statements)? -
i have array populated records 1 table , want count corresponding records table , insert array.
when try code keep getting error
warning: mysqli::prepare() [mysqli.prepare]: data must fetched before new statement prepare takes place
foreach ($persons $i=>$person) { $stmt = $mysqli->prepare("select count(*) order personid = ?"); $stmt->bind_param("i", $person['personid']); $stmt->execute(); $stmt->bind_result($totalorders); $stmt->fetch(); $stmt->close; $persons[$i]['totalorders'] = $totalorders; } it's though $stmt->close; being ignored.
you need add parentheses call close method:
$stmt->close();
Comments
Post a Comment