I have problems with mysql_fetch return the wrong records. If I execute the sql statement in mysql, I receive the correct results. When I used mysql_fetch function, it does not return the correct results. Below is my function and the format sql statement
function companiesByBusiness_ZipCode_BusinessOrContactName( $ctgyno, $zipcode, $businessandcontactname ) { $sql = "select company_no, name, contact, business_phone, mobile_phone, services_desc, brief_bio, pager, address, city, state, zipcode, picture_file, case ifnull(picture_file, 'No Picture') when 'No Picture' then 'b' else 'a' end pic_ind from company"; if( $ctgyno != "ALL") { $sql .= " where business_ctgy_no = $ctgyno"; if( $zipcode != "" ) { $sql .= " and (zipcode like '".substr( $zipcode, 0, 3 )."%' and zipcode != '$zipcode')"; } if( $businessandcontactname != "" ) { $sql .= " and (name = '$businessandcontactname'"; $sql .= " or contact = '$businessandcontactname')"; } $sql .= " order by pic_ind, name, company_no"; } $query = mysql_query( $sql ) or die( $sql."<p>".mysql_error() ); //$numrows = mysql_num_rows( $query ); while( $assoc = mysql_fetch_assoc( $query ) ) { $rows[] = $assoc; sql statement: select company_no, name, contact, business_phone, mobile_phone, services_desc, brief_bio, pager, address, city, state, zipcode, picture_file, case ifnull(picture_file, 'No Picture') when 'No Picture' then 'b' else 'a' end pic_ind from company where business_ctgy_no = 1 and (zipcode like '276%' and zipcode != '27616') and (name = 'Gil Bryan' or contact = 'Gil Bryan') order by pic_ind, name, company_no It seems like it is ignoring the last condition, name = 'Gil Bryan' or contact = 'Gil Bryan'). Any help is greatly appreciated. } return $rows; } -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php