I'm trying to print the result of mysql query from Firebird database. Query returns usually one row with 6 values. The code works up to here:
$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);
When I echo the num_results
in html, it show right value. But when I want to echo the values from database, nothing shows up.
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();
Does anybody know, what I'm doing wrong? I've tried many various possibilities how to print the Firebird query results but with no success. Thanks a lot.
BTW, the query looks like this:
$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'";
$result = ibase_query($con,$query);
while ($row = ibase_fetch_row($res))
{
foreach($row as $key => $value)
{
echo $key.": ".$value;
}
}
$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>
";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.