<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
// extract all the form fields and store them in variables
$WineType=$_POST['WineType'];
$Pairing=$_POST['Pairing'];
$PriceRange=$_POST['PriceRange'];
// the table will always have at three columns
$tablewidth = 600;
$sqlstatement = "SELECT * FROM wine1";
/* Set oracle user login and password info */
$dbuser = "xxxx"; /* your login */
$dbpass = "xxxx"; /* your password */
$db = "SSID";
$connect = oci_connect($dbuser, $dbpass, $db);
if (!$connect) {
echo "An error occurred connecting to the database";
exit;
}
/* build sql statement using form data */
$query = $sqlstatement;
/* check the sql statement for errors and if errors report them */
$stmt = oci_parse($connect, $query);
echo "SQL: $query<br>";
if(!$stmt) {
echo "An error occurred in parsing the sql string.\n";
exit;
}
oci_execute($stmt);
$howmany=0;
while(oci_fetch_array($stmt)) {
$howmany=$howmany+1;
}
echo "Number of items: $howmany<br>";
?>
<?php
oci_close($connect);
?>
</body>
</html>
こんにちは、上記のコードのため。私は、 "SELECT * from wine1;"を実行すると、oracleサーバーから返された行の数を数えようとしています。クエリ。phpからのSQLクエリから得られた行数
$カウントが私はSQLサーバー自体にクエリを送信する際、テーブルに格納されているすべての6つの項目を取得することが可能だということを確認したコード
を実行した後にゼロであるようです。それはちょうどPHPで動作するように見えません。
'oci_fetch_array'を変数に代入し、print_rの結果が' NULL'でないことを確認しましたか?また、あなたのSQLで 'COUNT'を使わない理由がありますか?例えば'選択カウント(*)からワイン'。 – doublesidedstickytape
私は実際に、ユーザが提出した検索基準に基づいて動的なウェブページを構築しています。私はカウントメソッドで行くだろう。 –