0

出力したいデータを指定するのに問題があります。私がやろうとしているのは、レシピ テーブルに含まれるすべてのレシピ タイトルを出力することです。

$stid2 = oci_parse($conn, 'select recipetitle from recipes.recipe');
oci_execute($stid2);

while ($row = oci_fetch_array($stid2, OCI_ASSOC)) {
  echo "<p>Sorry, there are no titles</p>";
    } else {
        echo '<p> <b>Recipe Title: </b>' . $row['recipetitle'] . '</p>';
    }
}

それは可能ですか?「識別されていないインデックス」エラーが発生します。

ありがとう

4

1 に答える 1

0

コメントしたように、while/elseは php には存在しません。

代わりに、試してください:

$stid2 = oci_parse($conn, 'SELECT `recipetitle` FROM `recipes`.`recipe`');
oci_execute($stid2);

//Output var
$output = '';

while ($row = oci_fetch_array($stid2, OCI_ASSOC)) {
    $output .= '<p> <b>Recipe Title: </b>' . $row['recipetitle'] . '</p><br>';
}

//Ternary test
$output == '' ? echo "<p>Sorry, there are no titles</p>" : echo $output;
于 2013-03-11T08:04:22.143 に答える