我加上了 $myrow = mysql_fetch_row($res);這一句想擷取一行資料 為什麼擷取不到一行 提示這個 ( ! ) Warning: mysql_fetch_row() expects parameter 1 to be resource, array given in D:\wamp\www\chaxun.php on line 7
prepare("select * from test"); $stmt->execute(); //$myrow = mysql_fetch_row($stmt->execute()); $res=$stmt->fetch(); $myrow = mysql_fetch_row($res); print_r($myrow);?>
回複內容:
我加上了 $myrow = mysql_fetch_row($res);這一句想擷取一行資料 為什麼擷取不到一行 提示這個 ( ! ) Warning: mysql_fetch_row() expects parameter 1 to be resource, array given in D:\wamp\www\chaxun.php on line 7
prepare("select * from test"); $stmt->execute(); //$myrow = mysql_fetch_row($stmt->execute()); $res=$stmt->fetch(); $myrow = mysql_fetch_row($res); print_r($myrow);?>
PDOStatement::rowCount — 返回受上一個 SQL 陳述式影響的行數
PDOStatement::fetch — 從結果集中擷取下一行
query('SELECT * from users');//擷取一行$result=$query->fetch();print_r($result);$total = $pdo->query('SELECT * from test');//統計條數$count=$total->rowCount();echo $count;
要用while迴圈取吧