I tried echo the sql in this function but I do not know where it print the
statement.  This function is inside *.inc file which is require in the html
that I am printing the results of the query.  So, to answer your question, I
using the data to display on a html page.  I am returning an array from this
function.
"David Robley" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> says...
> > 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;
> > }
>
> First, I'd suggest echoing $sql just before you send it to mysql to ensure
> that what you hope is there is actually there. Also, what are you
> returning from your function? Or how are you using the data gathered from
> your tables?
>
> --
> David Robley
> Temporary Kiwi!
>
> Quod subigo farinam



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

Reply via email to