Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: query

  1. #16
    Join Date
    Jun 2005
    Location
    coronado
    Posts
    76
    k, I have a question. In a combo box, I have the user select a company name and that name is then sent to the query. What I am trying to do is if no selection is made, the query would still run as if all the selections were made, returning all the companies which fall into that category. Do you know how to do this? I created an <option>ALL</option>, but ccant figure out what its value should be? Help?

  2. #17
    Join Date
    Apr 2005
    Location
    florida
    Posts
    89
    Let's assume that the company name combo's default value is 'all'

    if ($C_name=="all"){
    $company_name_cond=" and 1=1 ";
    }
    esle{
    $company_name_cond=" and c_name = $C_name ";
    }
    $sql="select * from company, activity
    where c_id = a_c_id and
    medivas = $poc and
    priority in ($prioritya, $priorityb, $priorityc) and
    a_date between $startdate and $enddate ".$company_name_cond;

  3. #18
    Join Date
    Jun 2005
    Location
    coronado
    Posts
    76
    amazing, what dont you know?

  4. #19
    Join Date
    Jun 2005
    Location
    coronado
    Posts
    76
    K, Now, the guy wants me to do away with selecting a certain company and want me to sort the list by prority, do you know how I would then link to the other page...(somewhat like this?)
    PHP Code:
        print "<TD ALIGN=CENTER><a href=showactivity.php?priority=$prioritya$priorityb$priorityc&start=$startdate&end=$enddate>".$result['c_name']."</TD>"
    then should my select statement on the next page be
    select c_name, c_state, c_city, contact_name, contact_phone, a_desc, a_next, medivas,
    DATE_FORMAT(a_date, '%m/%d/%Y') as a_date_formatted from company, activity
    where c_id = a_c_id and
    priority = '$priority' and
    a_date between '$start' and '$end'
    Last edited by lukeurtnowski; 07-12-2005 at 01:34 PM.

  5. #20
    Join Date
    Apr 2005
    Location
    florida
    Posts
    89
    I am not realy clear..

    You dont have to put priority in the search condition.

    print "<TD ALIGN=CENTER><a href=showactivity.php?&start=$startdate&end=$endda te>".$result['c_name']."</a></TD>";

    And the next page query should be some like:
    select c_name, c_state, c_city, contact_name, contact_phone, a_desc, a_next, medivas,
    DATE_FORMAT(a_date, '%m/%d/%Y') as a_date_formatted from company, activity
    where c_id = a_c_id and
    a_date between '$start' and '$end'
    and c_name = '$company_name_chosen'
    oder by priority asc

  6. #21
    Join Date
    Jun 2005
    Location
    coronado
    Posts
    76
    ok, sounnd good, thanks, i'll try that (your right.....I bet you were a boy genius or something like that) Dop you do this for a living?
    Last edited by lukeurtnowski; 07-12-2005 at 02:45 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •