我无法指定要输出的数据,我正在尝试打印的是配方表中包含的所有配方标题。
$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>';
}
}
这甚至可能吗?我刚收到'未识别的索引'错误。
由于
答案 0 :(得分:0)
正如我评论的那样,php中不存在while
/ else
。
相反,请尝试:
$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;