Jump to content

SQL conversion


maliary

Recommended Posts

  • Replies 57
  • Created
  • Last Reply

 

Sorry for being so vague.

 

Well, what i mean is when i try searching using either the last name,  first name  or pid with the date range it doesn't give any results, when it actually should be.

 

Searching using a number with the date range -- for the encounter_nr -- produces the correct search results.

 

Here is the form that does the search,if it helps

 

<FORM action="<?php echo $thisfile; ?>" method="post" name="sform" onSubmit="return checkForm(sform.keyword)">

<B><?php echo 'Enter Date Range' ?></B></font><p>
From:<font size=3>
<INPUT  READONLY  type="text" name="from_date" size="20" maxlength="40" value=<?php echo '"'.$sBdayBuffer.'" '.$sDateJSfrom.' '?> </font>
<p></p>
To:    <font size=3>
<INPUT  READONLY   type="text" name="to_date" size="20" maxlength="40" value=<?php echo '"'.$sBdayBuffer.'" '.$sDateJSto.''?> </font>
<p></p>
<INPUT type="text" name="keyword" size="20" maxlength="40" value="<?php echo $keyword ?>"></font>
<input type=hidden name="search" value=1>  
<input type=hidden name="from" value="<?php echo $from_date ?>">
<input type=hidden name="to" value="<?php echo $to_date ?>"> 
<input type=submit name="submit" value=submit> 

</FORM>

Link to comment
https://forums.phpfreaks.com/topic/49668-sql-conversion/page/3/#findComment-257531
Share on other sites

 

Yes I have,

 

The search key is passed through all the variables. But it still doesn't work.

I broke down the query into 3 parts and tested the individual tables.

 

this produces the required results when a name is passed through as the search key.

 


$SQL="SELECT p.name_last,p.name_first, f.*,e.*
        FROM   care_person AS p
        INNER JOIN care_encounter AS e  ON p.pid = e.pid
        INNER JOIN care_test_findings_chemlab AS f ON e.encounter_nr = f.encounter_nr WHERE  test_date  BETWEEN '".$pn."' AND '".$cw."' OR  p.name_last LIKE '$key%'  ";   
                                                                                                                         

 

when I try searching using both encounter number and search key. I find that it can only search using the encounter key but the search using the name stops working.

 

 


$SQL="SELECT p.name_last,p.name_first, f.*,e.*
        FROM   care_person AS p
        INNER JOIN care_encounter AS e  ON p.pid = e.pid
        INNER JOIN care_test_findings_chemlab AS f ON e.encounter_nr = f.encounter_nr WHERE  test_date  BETWEEN '".$pn."' AND '".$cw."' AND  (p.name_last LIKE '$key%' OR e.encounter_nr=$key) ";   
                                                                                                                         

Link to comment
https://forums.phpfreaks.com/topic/49668-sql-conversion/page/3/#findComment-258940
Share on other sites

  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.