Hello,
I want to count the number of row returned by a query, so I can try to manipulate how many rows are printed to the screen at a time. I am using an Informix (v 7.2) database, so I don't have access to SQL commands (FIRST N or LIMIT)...very limited SQL commands.
Basically, I trying to count the number of rows, so I can manipulate string so it shows ten rows at a time and give the user an option of viewing the next ten hits. I still have yet to figure out how I am going to truncate it, but thanks for any help...
$dbConnection=ifx_pconnect();
if(!$dbConnection) die("Could not connect");
$keywordQueryPrepare=ifx_prepare("SELECT DISTINCT title, desc, url FROM webSearch WHERE UPPER(desc) LIKE UPPER('%$query%')", $dbConnection);
$tkeywordQueryPrepare=ifx_prepare("SELECT DISTINCT title, desc, url FROM webSearch WHERE UPPER(desc) LIKE UPPER('%$query%')", $dbConnection);
$keywordQuery=ifx_do($keywordQueryPrepare);
$tkeywordQuery=ifx_do($tkeywordQueryPrepare);
if (!$keywordQuery) die("Query failed");
$afRows=ifx_affected_rows($tkeywordQueryPrepare);
for ($i=0; $i<=$afRows; $i++){
$k=ifx_fetch_row($tkeywordQueryPrepare);
}
$nRows=ifx_num_rows($tkeywordQueryPrepare);
echo $nRows;
$row=ifx_fetch_row($keywordQueryPrepare);
printf("<br>");
while (is_array($row)) {
for(reset($row); $fieldName=key($row); next($row)) {
if ($fieldName==title){
$fieldValue=$row[$fieldName];
$title=$fieldValue;
}
if ($fieldName==desc){
$fieldValue=$row[$fieldName];
$desc=$fieldValue;
}
if ($fieldName==url) {
$fieldValue=$row[$fieldName];
$url=$fieldValue;
}
}
$i++;
if ($i%2) $rowBackGround="e3ecf4";
else $rowBackGround="f9f9f9";
printf("<tr bgColor='$rowBackGround'>");
printf("<br><a href='$url'>");
printf($title);
printf("</a><br>");
printf("<b><i><font color='#31417B'>Discription: </font></b></i>");
printf($desc);
printf("<br>");
printf("<font size='2'><i><a href='$url'>");
printf($url);
printf("</a></i></font><br><br>");
printf("<tr>");
$row=ifx_fetch_row($keywordQueryPrepare);
}
printf("<tr>");
printf("</tr>");
printf("<tr>");
printf("<font color='#31417B'><a href='#'>[Prev]</a> somenumbers <a href='#'>[Next]</a></font>");
printf("</tr>");
echo $row;
ifx_free_result($keywordQueryPrepare);
$dbConnection=ifx_close();
?>