Re: Row Count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniel Brown wrote:
On Tue, Jun 10, 2008 at 10:11 AM, Dan Shirah <mrsquash2@xxxxxxxxx> 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 Brown, did you read through this too quickly also???

You and Jay both need to slow down a bit...

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux