Re: Row Count
| From: | Jim Lucas | Date: | Tue, 10 Jun 2008 14:54:50 +0000 |
| Subject: | Re: Row Count | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275191@lists.php.net to get a copy of this message | ||
Daniel Brown wrote:
On Tue, Jun 10, 2008 at 10:11 AM, Dan Shirah <mrsquash2@gmail.com> wrote: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 ShakespeareIf 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 SQLstandard "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 CONNECTIONecho "Unable to connect to Informix Database\n"; // DISPLAY IFCONNECTION FAILSexit(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 .= " WHEREjudge_name='".mysql_real_escape_string($judge_code)."'"; } elseif(empty($judge_code) && !empty($case_age)) {$query .= " WHEREcase_age_group='".mysql_real_escape_string($case_age)."'"; } elseif(!empty($judge_code) && !empty($case_age)) {$query .= " WHEREjudge_name='".mysql_real_escape_string($judge_code)."'";$query .= " ANDcase_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]; ?>