Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6120631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:41:25+00:00 2026-05-23T15:41:25+00:00

i have this query and code if(isset($_REQUEST[‘main_task’]) && ($_REQUEST[‘main_task’] !=”)) { $query_task = SELECT

  • 0

i have this query and code

if(isset($_REQUEST['main_task']) && ($_REQUEST['main_task'] !='')) {
    $query_task  = "SELECT * from manage_project_task where  prj_task_name LIKE  '%".$_REQUEST['main_task']."%' and prj_task_parent_id='0'";//Sort Main Task
} else {
    $query_task  = "SELECT * from manage_project_task where prj_task_project_id=$project_id  and prj_task_parent_id='0'";//Sort Main Task
}

$SelectQuery = $query_task." LIMIT ".$start.",".$limit."";      
$result_task =  $db->GetALL($SelectQuery);  
$cnt_task=count($result_task);
if ($db->Affected_Rows($result_task)>0)         
{   
    for ($i=0;$i<$cnt_task;$i++) { 
        $actual_hours_worked=0;         
        $actual_hours_worked2=0;

        // subtask hyperlink
        if (isset($_REQUEST['sub_task']) && ($_REQUEST['sub_task'] !='')) {
            $query_subtask1  = "SELECT * from manage_project_task where prj_task_parent_id='".$result_task[$i]['prj_task_id']."' AND prj_task_name LIKE '%".$_REQUEST['sub_task']."%'";
        } else {
            $query_subtask1  = "SELECT * from manage_project_task where prj_task_parent_id='".$result_task[$i]['prj_task_id']."'";
        }
        $result_subtask1 =  $db->GetALL($query_subtask1);
        $cnt_subtask1=count($result_subtask1);
    }
}

this gives me main tasks and sub task in serial pattern .Now I have taken 2 textfield 1 for main task and 2nd for sub task now if i only entered subtsk in 2nd textfield then it searches the subtask with its main task but along with it also give in result the remaining main task like this

  • main task
  • sub task (matching string in 2nd field)
  • main task
  • main task
  • main task
  • main task

I think its because the second loop depends on first one.So my question is hw can get only matching subtask with its main task and not the remaining main tasks??
Please sugest any solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:41:26+00:00Added an answer on May 23, 2026 at 3:41 pm

    In the 6th line of your code you overwrite the $query_task variable so the $_REQUEST['main_task'] makes no difference. This is why every main task is listed, like there were no search string given.

    Edit: if you have 3 matching tasks and 2 matching subtasks in the first matching task, you would get the result you describe. What you have to do is: use only those task which have matching subtasks.

    Making it simple: loop through the matching tasks (like you do) but only if you find a matching subtask inside it, add that task to the ones you want to display.

    $displayed_tasks = array();
    /* Query for matching tasks */
    foreach ($matched_tasks as $t)
    {
        /* Query for matching subtasks */
        if (!empty($matched_subtasks))
        {
            $displayed_tasks[] = $t;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query: SELECT page.id, revision.title, revision.number FROM page INNER JOIN revision ON
I have this query in sql server 2000: select pwdencrypt('AAAA') which outputs an encrypted
I have this query in LINQ to Entities. var query = (from s in
I have this query this.FixturePartidoPuntaje.Load(); var partidos = from q in this.FixturePartidoPuntaje where (
i have this code it can go to if(array_key_exists('p',$_POST)) but can't go to if(isset($_POST['p'][$i])
I have this code <?php session_start(); if (isset($_GET[cmd])) $cmd = $_GET[cmd]; else die(You should
i need again your help... I have this php code: <? if(isset($_POST['addnews'])){ $type =
I have this code that fetches data from mySQL and outputs it as an
I have this php code line $data['viewData']['filter'] = isset($parameters['filter']) ? $parameters['filter'] : array('filter1', 'filter2',
I have this code: $rows = array(); $res = mysql_query($someQuery); if(!mysql_errno()) while($row = mysql_fetch_assoc($res))

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.