Demo 5 - Select a count from a table
Informix error: %s", ifx_errormsg());
die;
}
}
$database = "video";
$server = "lapdog_tcp";
$login = "username";
$password = "password";
$dbs = $database . "@" . $server;
$connect_id = ifx_pconnect($dbs,$login,$password);
if (!$connect_id) {
echo "Unable to connect to Informix database
\n";
chk_ifx_err1($connect_id);
} else {
echo "Informix connection successful!
";
}
if ($connect_id) {
$statmt_txt = "select count(*) count from vhs where type_code = 'ST1' ";
$statmt_id1 = ifx_query($statmt_txt,$connect_id); // EXECUTE SQL
if (!$statmt_id1) {
echo "Unable to execute Informix sql statement
\n";
echo "$statmt_txt
\n";
chk_ifx_err1($statmt_id1);
}
$row = ifx_fetch_row($statmt_id1); // FETCH RESULT OF COUNT INTO ARRAY
if (!$row) {
echo "Unable to fetch Informix result
\n";
echo "$statmt_txt
\n";
chk_ifx_err1($statmt_id1);
}
$num_rows_selected = sprintf("%d",$row[count]); // FORMAT COUNT INTO VARIABLE
echo "";
echo "$num_rows_selected rows selected
"; // DISPLAY RESULT IN HTML
echo "";
ifx_free_result ($statmt_id1);
}
?>