Firebird数据库中的回显行值

时间:2018-03-28 11:34:52

标签: php html echo firebird

我正在尝试从Firebird数据库打印mysql查询的结果。 查询通常返回一行,包含6个值。代码可以在这里工作:

$result = ibase_query($con,$query);

function ibase_num_rows($query) { 
    $i = 0;
    while (ibase_fetch_row($query)) {
        $i++;
    }
    return $i;
}

$num_results = ibase_num_rows($result);

当我在html中回显num_results时,它显示正确的值。但是当我想回显数据库中的值时,什么都没有出现。

for ($i=0; $i <$num_results; $i++) {
    $row = ibase_fetch_object($result);

    echo "
        <div class='container'>
        <hr>
        <div class='row'>
        <div class='col-lg-7'>
    ";

    echo "
        <p><strong>".($i+1).". something: 
        $row[0]
        </strong><br /><strong>something: 
        $row[1]
        </strong><br />something: 
        $row[2]
        </strong><br/>something: 
        $row[3]
        </strong><br/>something: 
        $row[4]
        <br/>something: 
        $row[5]
        </p>
        </div>
    ";

    // ...
}
$result->free();
$con->ibase_close();

有人知道吗,我做错了什么?我已经尝试了很多种可能性如何打印Firebird查询结果,但没有成功。 非常感谢。

BTW,查询如下:

$query = "SELECT STOREBATCHES.NAME, STOREBATCHES.NOTE, STORECARDS.NAME, STORECARDS.CODE, STORESUBBATCHES.QUANTITY, USERDATA.STRINGFIELDVALUE";
$query.= " FROM STOREBATCHES";
$query.= " JOIN STORECARDS";
$query.= " ON STOREBATCHES.STORECARD_ID = STORECARDS.ID";
$query.= " JOIN STORESUBBATCHES";
$query.= " ON STOREBATCHES.ID = STORESUBBATCHES.STOREBATCH_ID";
$query.= " JOIN USERDATA";
$query.= " ON STOREBATCHES.ID = USERDATA.ID";
$query.= " WHERE STOREBATCHES.NAME = '".$searchterm."' AND STORESUBBATCHES.STORE_ID = '1000000101'";

2 个答案:

答案 0 :(得分:0)

$result = ibase_query($con,$query);

while ($row = ibase_fetch_row($res)) 
{
    foreach($row as $key => $value) 
    {
        echo $key.": ".$value;
    }
 }

答案 1 :(得分:0)

$result = ibase_query($con,$query);
while($row = ibase_fetch_row($result))
{
  foreach($row as $key => $value)
{
  $value; (if you want particular value then write a if condition here.)
}
}
echo "
<div class='container'>
<hr>
<div class='row'>
<div class='col-lg-7'>
";

     echo "
     <p><strong>'.$value.'
     </strong><br /><strong>
     </p>
     </div>
     ";

  }