【问题标题】:Specifying and printing columns in an Oracle Database在 Oracle 数据库中指定和打印列
【发布时间】:2013-03-11 07:22:15
【问题描述】:

我无法指定我希望输出的数据,我正在尝试打印配方表中包含的所有配方标题。

$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>';
    }
}

这可能吗?我只是收到“未识别的索引”错误。

谢谢

【问题讨论】:

  • While / else 在 php 中不存在。

标签: php sql oracle


【解决方案1】:

正如我所评论的,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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 2018-09-26
    • 2010-09-22
    相关资源
    最近更新 更多