我想使用以下代码获取数据:
if(isset($_POST['btnSubmit']))
{
/* connect using pdo */
try
{
$db_conn = new PDO('mysql:host=localhost; dbname =database','username','password');
}
catch (PDOException $e) {
echo "could not connect to database.";
exit;
}
$password=$_POST['password'];
$selectSQL = "SELECT fac_id, username, password, type, user_prefix FROM faculty WHERE username = ? AND password = ?";
$stmt = $db_conn->prepare($selectSQL);
$stmt->execute(array($_POST['username'],$password));
while($abc = $stmt->fetch())
{
print_r($abc);
}
echo $rowCount = count($stmt);
die;
}
预期结果:
所有行+行数。
我得到什么:
只有行数。