On Tue, Jun 10, 2008 at 10:11 AM, Dan Shirah <[EMAIL PROTECTED]> wrote:
>
> If I do not put in any serch criteria and my basic query ends up being
> "SELECT * FROM brev_pending_summary_detail" then the value of $rowcount is
> 110796. If one search criteria is used the value of $rowcount becomes 11080.
> If both criteria are used the value of $rowcount is 1108. 110796 is the
> correct value of my total rows in the table, but the other two values are
> inncorrect and appear to just be one digit shorter and rounded off.
You may also want to look into getting the number from the SQL
standard "SELECT COUNT(*) ...." query.
> My query is below:
This should be rewritten a bit, really....
[snip="code"]
<?php
$connect_id = ifx_connect($database."@".$host, $user, $pass);
if(!$connect_id) { // THE ACTUAL CONNECTION
echo "Unable to connect to Informix Database\n"; // DISPLAY IF
CONNECTION FAILS
exit(1);
}
$query = "SELECT * FROM brev_pending_summary_detail"; // BASIC QUERY
// Uncomment this to use the alternative method:
//$query = "SELECT COUNT(*) FROM brev_pending_summary_detail";
if(!empty($judge_code) && empty($case_age)) {
$query .= " WHERE
judge_name='".mysql_real_escape_string($judge_code)."'";
} elseif(empty($judge_code) && !empty($case_age)) {
$query .= " WHERE
case_age_group='".mysql_real_escape_string($case_age)."'";
} elseif(!empty($judge_code) && !empty($case_age)) {
$query .= " WHERE
judge_name='".mysql_real_escape_string($judge_code)."'";
$query .= " AND
case_age_group='".mysql_real_escape_string($case_age)."'";
}
$count_query = ifx_query($query,$connect_id);
$rowcount = ifx_affected_rows($count_query);
echo $rowcount;
// Uncomment below and comment-out the above to use the alternative method.
$result = ifx_query($query,$connect_id);
$row = ifx_fetch_row($result);
echo $row[0];
?>
--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php