Jump to content

turning html into if else


kenny724

Recommended Posts

how would I turn this html code into an if else state...if the $md_sig is not there...the others aren't supposed to show up. If the md approves it and the$md_sig is there...all the other sigs need to populate

 

<tr>

<td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>

<table border="0" width="100%">

<tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>

<tr>

<td valign="bottom">$md_sig<hr />Psychiatrist: $md_name_string</td>

<td valign="bottom">$approved_date_string <hr />Date:</td>

</tr>

<tr>

<td valign="bottom">$case_manager_sig<hr />Case Manager: $case_manager_name_string</td>

<td valign="bottom">$case_date_string <hr />Date:</td>

</tr>

<tr>

<td valign="bottom">$therapist_sig<hr />Therapist: $therapist_name_string</td>

<td valign="bottom">$therapist_date_string <hr />Date:</td>

</tr>

<tr>

<td valign="bottom">$activity_therapist_sig<hr />Activity Therapist: $activity_therapist_name_string</td>

<td valign="bottom">$activity_date_string <hr />Date:</td>

</tr>

<tr>

<td valign="bottom">$other_sig<hr />Other: $other_name_string</td>

<td valign="bottom">$other_date_string <hr />Date:</td>

</tr>

<tr>

<td colspan="2"><br />NEXT TREATMENT PLAN REVIEW: <font class="dbd">$next_review</font></td>

</tr>

</table>

</td>

</tr>

Link to comment
Share on other sites

if i understand you properly, and all you want is to blank the info if the md_sig is not there, then you could

 

<?php
if (empty($md_sig)) {
$case_manager_sig = '';
$therapist_sig = '';
$activity_therapist_sig = '';
$other_sig = '';
}
?>

 

you could also throw the dates in there if those need to be unset. this way you do it before the html and you don't have to if anything there , the strings will just be blank if  md_sig was blank.

Link to comment
Share on other sites

both of those should have worked, i think you need to show us your code

 

var_dump($mp_sig); //before the if statement, so you know it is in fact empty.

 

also copy and post the if else you made in regards to the post before mine, as that should have worked and there's probably something in the code wrong.

Link to comment
Share on other sites

<?php

 

if(file_exists($md_sig))

{

 

<tr>

<td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>

<table border="0" width="100%">

<tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>

<tr>

<td valign="bottom">$md_sig<hr />Psychiatrist: $md_name_string</td>

<td valign="bottom">$md_date_string<hr />Date:</td>

</tr>

<tr>

<td valign="bottom">$case_manager_sig<hr />Case Manager: $case_manager_name_string</td>

<td valign="bottom">$case_date_string <hr />Date:</td>

</tr>

<tr>

<td valign="bottom">$therapist_sig<hr />Therapist: $therapist_name_string</td>

<td valign="bottom">$therapist_date_string <hr />Date:</td>

</tr>

<tr>

<td valign="bottom">$activity_therapist_sig<hr />Activity Therapist: $activity_therapist_name_string</td>

<td valign="bottom">$activity_date_string <hr />Date:</td>

</tr>

<tr>

<td valign="bottom">$other_sig<hr />Other: $other_name_string</td>

<td valign="bottom">$other_date_string <hr />Date:</td>

</tr>

<tr>

<td colspan="2"><br />NEXT TREATMENT PLAN REVIEW: <font class="dbd">$next_review</font></td>

</tr>

</table>

</td>

</tr> }

 

else {

 

<tr>

<td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>

<table border="0" width="100%">

<tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>

<tr>

<td valign="bottom"><hr />Psychiatrist: $md_name_string</td>

<td valign="bottom">$md_date_string<hr />Date:</td>

</tr>

<tr>

<td valign="bottom"><hr />Case Manager: $case_manager_name_string</td>

<td valign="bottom">$case_date_string <hr />Date:</td>

</tr>

<tr>

<td valign="bottom"><hr />Therapist: $therapist_name_string</td>

<td valign="bottom">$therapist_date_string <hr />Date:</td>

</tr>

<tr>

<td valign="bottom"><hr />Activity Therapist: $activity_therapist_name_string</td>

<td valign="bottom">$activity_date_string <hr />Date:</td>

</tr>

<tr>

<td valign="bottom"><hr />Other: $other_name_string</td>

<td valign="bottom">$other_date_string <hr />Date:</td>

</tr>

<tr>

<td colspan="2"><br />NEXT TREATMENT PLAN REVIEW: <font class="dbd">$next_review</font></td>

</tr>

</table>

</td>

</tr> }

?>

Link to comment
Share on other sites

This is at very top

)) { } else { } ?>

 

 

and this comes out where it should. The first has signatures, but the second doesn't. It's doesn't show here though..but it's listed wice

 

 

TREATMENT TEAM SIGNATURES

Services ordered are Appropriate�See SMI/SED for additional explanation

 

 

 

Psychiatrist: Waiting for Approval Date:

testCase Manager: Jacqueline Thomas 02/02/2012 Date:

testTherapist: Devonda Newsome 02/02/2012 Date:

 

 

 

Activity Therapist: Date:

testOther: Denita Malone 02/02/2012 Date:

 

NEXT TREATMENT PLAN REVIEW: 05/08/2012

 

TREATMENT TEAM SIGNATURES

Services ordered are Appropriate�See SMI/SED for additional explanation

Psychiatrist: Waiting for Approval Date:

Case Manager: Jacqueline Thomas 02/02/2012 Date:

Therapist: Devonda Newsome 02/02/2012 Date:

Activity Therapist: Date:

Other: Denita Malone 02/02/2012 Date:

 

NEXT TREATMENT PLAN REVIEW: 05/08/2012

Link to comment
Share on other sites

not according to what you posted. that is a weird mixture of php and html and should not work at all.

 

<?php

if(file_exists($md_sig))
   { ?>

<tr>
   <td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>
      <table border="0" width="100%">
         <tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>
         <tr>
            <td valign="bottom">$md_sig<hr />Psychiatrist: $md_name_string</td>
            <td valign="bottom">$md_date_string<hr />Date:</td>
         </tr>
         <tr>
            <td valign="bottom">$case_manager_sig<hr />Case Manager: $case_manager_name_string</td>
            <td valign="bottom">$case_date_string <hr />Date:</td>
         </tr>
         <tr>
            <td valign="bottom">$therapist_sig<hr />Therapist: $therapist_name_string</td>
            <td valign="bottom">$therapist_date_string <hr />Date:</td>
         </tr>
         <tr>
            <td valign="bottom">$activity_therapist_sig<hr />Activity Therapist: $activity_therapist_name_string</td>
            <td valign="bottom">$activity_date_string <hr />Date:</td>
         </tr>
         <tr>
            <td valign="bottom">$other_sig<hr />Other: $other_name_string</td>
            <td valign="bottom">$other_date_string <hr />Date:</td>
         </tr>
         <tr>
            <td colspan="2"><br />NEXT TREATMENT PLAN REVIEW: <font class="dbd">$next_review</font></td>
         </tr>
      </table>   
   </td>
</tr> <?php }

else { ?>

<tr>
   <td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>
      <table border="0" width="100%">
         <tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>
         <tr>
            <td valign="bottom"><hr />Psychiatrist: $md_name_string</td>
            <td valign="bottom">$md_date_string<hr />Date:</td>
         </tr>
         <tr>
            <td valign="bottom"><hr />Case Manager: $case_manager_name_string</td>
            <td valign="bottom">$case_date_string <hr />Date:</td>
         </tr>
         <tr>
            <td valign="bottom"><hr />Therapist: $therapist_name_string</td>
            <td valign="bottom">$therapist_date_string <hr />Date:</td>
         </tr>
         <tr>
            <td valign="bottom"><hr />Activity Therapist: $activity_therapist_name_string</td>
            <td valign="bottom">$activity_date_string <hr />Date:</td>
         </tr>
         <tr>
            <td valign="bottom"><hr />Other: $other_name_string</td>
            <td valign="bottom">$other_date_string <hr />Date:</td>
         </tr>
         <tr>
            <td colspan="2"><br />NEXT TREATMENT PLAN REVIEW: <font class="dbd">$next_review</font></td>
         </tr>
      </table>   
   </td>
</tr> <?php }
?>

 

would work assuming it's actually html it just has that php in it. otherwise you would need an echo or print in there somewhere.

 

you have html and php mixed with nothing to tell it what's what.

<?php <td valign="bottom">$md_date_string<hr />Date:</td> ?>

 

same thing here. you need an echo or print there.

</tr> }

else {

<tr>

 

something like this instead:

<?php

if(file_exists($md_sig))
   {
echo '
<tr>
   <td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>
      <table border="0" width="100%">
         <tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>
         <tr>
            <td valign="bottom">'. $md_sig. '<hr />Psychiatrist: '. $md_name_string. '</td>
            <td valign="bottom">'. $md_date_string. '<hr />Date:</td>
         </tr>
         <tr>
            <td valign="bottom">'. $case_manager_sig. '<hr />Case Manager: '. $case_manager_name_string. '</td>
            <td valign="bottom">'. $case_date_string. '<hr />Date:</td>
         </tr>
      </table>   
   </td>
</tr>'; }
?>

 

i'd say you are seeing it twice because it is not parsing it as php at all. so it sees two tables and ignored the if statement.

Link to comment
Share on other sites

so you are using heredoc? that's why the code looked wrong to me, as i couldn't see that.

i have never used an if inside a heredoc statement, so i'm at a bit of a loss. i would think you need to end the heredoc for the if statement, but i don't know.

 

i'd venture that's where your problem lies though. "if else in heredoc"

Link to comment
Share on other sites

Should I add the empty if statement into the signature.inc file?

 

<?php

// Include this file to add signatures to the print output
// This file will set two signature variables: md_sig and clinician_sig

//first step is to use the query results from the cpt_form.inc for the billed_by var
if(IsSet($billed_by))
$sql_query = "SELECT sig_file, user_first_name, user_last_name FROM users_table WHERE user_id_pk = $billed_by";
else
$sql_query = "SELECT sig_file, user_first_name, user_last_name FROM users_table WHERE user_id_pk = $completed_by_fk";
//echo "clinician_sig: $sql_query <br />";
$sql_query_result = mysql_query($sql_query) or die ("Error in sql_query signatures.inc");
$sql_array = mysql_fetch_array($sql_query_result);
$clinician_sig = $sql_array[0];
$clinician_name_string = "$sql_array[1] $sql_array[2]";

if(file_exists($clinician_sig))
$clinician_sig = "<img src=\"$clinician_sig\" border=\"0\" />";

else
$clinician_sig = "<br /><br /><br />";

//now clean up the date format
if(IsSet($completed_date))
$completed_date_string = strftime("%m/%d/%Y", strtotime($completed_date));
else
$completed_date_string="";

if(IsSet($approved_by) && $approved_by != "")
{
$sql_query = "SELECT sig_file, user_first_name, user_last_name FROM users_table WHERE user_id_pk = $approved_by";
//echo "md_sig: $sql_query <br />";
$sql_query_result = mysql_query($sql_query) or die ("Error in sql_query2 signatures.inc");
$sql_array = mysql_fetch_array($sql_query_result);
$md_sig = $sql_array[0];
//echo "sig: $md_sig <br />";
$md_name_string = "$sql_array[1] $sql_array[2]";

if(file_exists($md_sig))
{
	$md_sig = "<img src=\"$md_sig\" border=\"0\" alt=\"\" />";
$md_date_string = strftime("%m/%d/%Y", strtotime(approved_date));
}

else
{
	$md_sig = "<br /><br /><br />";
}	
//now clean up the date format
$approved_date_string = strftime("%m/%d/%Y", strtotime($approved_date));
}
else
{
$md_sig = "<br /><br /><br />";
$md_name_string = "Waiting for Approval";
$md_date_string="";
}

if(IsSet($psychiatrist_id_fk) && $psychiatrist_id_fk != 0)
{
$sql_query = "SELECT sig_file, user_first_name, user_last_name FROM users_table WHERE user_id_pk = $psychiatrist_id_fk";
//echo "md_sig: $sql_query <br />";
$sql_query_result = mysql_query($sql_query) or die ("Error in sql_query2 signatures.inc");
$sql_array = mysql_fetch_array($sql_query_result);
$psychiatrist_sig = $sql_array[0];
$psychiatrist_name_string = "$sql_array[1] $sql_array[2]";

if(file_exists($psychiatrist_sig))
	$psychiatrist_sig = "<img src=\"$psychiatrist_sig\" border=\"0\" alt=\"test\" />";
	$approved_date_string = strftime("%m/%d/%Y", strtotime($approved_date));


}
else
{
$psychiatrist_sig = "<br /><br /><br />";
$psychiatrist_name_string = "Not Assigned";
$approved_date_string="";
}

if(IsSet($therapist_id_fk) && $therapist_id_fk != 0)
{
$sql_query = "SELECT sig_file, user_first_name, user_last_name FROM users_table WHERE user_id_pk = $therapist_id_fk";
//echo "md_sig: $sql_query <br />";
$sql_query_result = mysql_query($sql_query) or die ("Error in sql_query2 signatures.inc");
$sql_array = mysql_fetch_array($sql_query_result);
$therapist_sig = $sql_array[0];
$therapist_name_string = "$sql_array[1] $sql_array[2]";

if(file_exists($therapist_sig))
	$therapist_sig = "<img src=\"$therapist_sig\" border=\"0\" alt=\"test\" />";
	$therapist_date_string = strftime("%m/%d/%Y", strtotime($completed_date));


}
else
{
$therapist_sig = "<br /><br /><br />";
$therapist_name_string="";
$therapist_date_string="";
}

if(IsSet($activity_therapist_id_fk) && $activity_therapist_id_fk != 0)
{
$sql_query = "SELECT sig_file, user_first_name, user_last_name FROM users_table WHERE user_id_pk = $activity_therapist_id_fk";
//echo "md_sig: $sql_query <br />";
$sql_query_result = mysql_query($sql_query) or die ("Error in sql_query2 signatures.inc");
$sql_array = mysql_fetch_array($sql_query_result);
$activity_therapist_sig = $sql_array[0];
$activity_therapist_name_string = "$sql_array[1] $sql_array[2]";

if(file_exists($activity_therapist_sig))
	$activity_therapist_sig = "<img src=\"$activity_therapist_sig\" border=\"0\" alt=\"test\" />";
    $activity_date_string = strftime("%m/%d/%Y", strtotime($completed_date));


}
else
{
$activity_therapist_sig = "<br /><br /><br />";
$activity_therapist_name_string="";
$activity_date_string="";
}

if(IsSet($case_manager_id_fk) && $case_manager_id_fk != 0)
{
$sql_query = "SELECT sig_file, user_first_name, user_last_name FROM users_table WHERE user_id_pk = $case_manager_id_fk";
//echo "md_sig: $sql_query <br />";
$sql_query_result = mysql_query($sql_query) or die ("Error in sql_query2 signatures.inc");
$sql_array = mysql_fetch_array($sql_query_result);
$case_manager_sig = $sql_array[0];
$case_manager_name_string = "$sql_array[1] $sql_array[2]";

if(file_exists($case_manager_sig))
	$case_manager_sig = "<img src=\"$case_manager_sig\" border=\"0\" alt=\"test\" />";
    $case_date_string = strftime("%m/%d/%Y", strtotime($completed_date));
}
else
{
$case_manager_sig = "<br /><br /><br />";
$case_manager_name_string="";
$case_date_string="";
}


if(IsSet($other_id_fk) && $other_id_fk != 0)
{
$sql_query = "SELECT sig_file, user_first_name, user_last_name FROM users_table WHERE user_id_pk = $other_id_fk";
//echo "md_sig: $sql_query <br />";
$sql_query_result = mysql_query($sql_query) or die ("Error in sql_query2 signatures.inc");
$sql_array = mysql_fetch_array($sql_query_result);
$other_sig = $sql_array[0];
$other_name_string = "$sql_array[1] $sql_array[2]";

if(file_exists($other_sig))
	$other_sig = "<img src=\"$other_sig\" border=\"0\" alt=\"test\" />";
	$other_date_string = strftime("%m/%d/%Y", strtotime($completed_date));

	}
else
{
	$other_sig = "<br /><br /><br />";
	$other_name_string="";
        $other_date_string="";
}


?>

Link to comment
Share on other sites

i said if else in heredoc because that is what you need info on, a google search returned this:

http://stackoverflow.com/questions/7187226/if-else-with-heredoc-not-behaving-as-expected

along with a few others. it's not possible to do your if statement inside your heredoc (EOL)

 

the code i gave you WILL work if you put it BEFORE the heredoc starts (<<<EOL). honestly heredoc is not the best way to do this project, but if you're set on that you need to do it differently. the link i posted has an example that shows how it must be done.

 

sorry bud ;(

 

 

Link to comment
Share on other sites

Ok, I tried it this way and the signatures aren't show up at all again. This is so confusing. The signatures are in a signatures.inc file...and it's included.

 

if(file_exists($md_sig))

  {

echo '

<tr>

  <td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>

      <table border="0" width="100%">

        <tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>

        <tr>

            <td valign="bottom">'. $md_sig. '<hr />Psychiatrist: '. $md_name_string. '</td>

            <td valign="bottom">'. $md_date_string. '<hr />Date:</td>

        </tr>

        <tr>

            <td valign="bottom">'. $case_manager_sig. '<hr />Case Manager: '. $case_manager_name_string. '</td>

            <td valign="bottom">'. $case_date_string. '<hr />Date:</td>

        </tr>

      </table> 

  </td>

</tr>'; }

 

 

else {

 

echo '

<tr>

  <td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>

      <table border="0" width="100%">

        <tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>

        <tr>

            <td valign="bottom"><hr />Psychiatrist: '. $md_name_string. '</td>

            <td valign="bottom">'. $md_date_string. '<hr />Date:</td>

        </tr>

        <tr>

            <td valign="bottom"><hr />Case Manager: '. $case_manager_name_string. '</td>

            <td valign="bottom">'. $case_date_string. '<hr />Date:</td>

        </tr>

      </table> 

  </td>

</tr>'; }

}

 

Link to comment
Share on other sites

HOT DAMN!!!!! I FIGURED IT OUT.  I DID IT THIS WAY:

 

if($md_date_string != "")
   {
echo '
<tr>
   <td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>
      <table border="0" width="100%">
         <tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>
         <tr>
            <td valign="bottom">'. $md_sig. '<hr />Psychiatrist: '. $md_name_string. '</td>
            <td valign="bottom">'. $md_date_string. '<hr />Date:</td>
         </tr>
         <tr>
            <td valign="bottom">'. $case_manager_sig. '<hr />Case Manager: '. $case_manager_name_string. '</td>
            <td valign="bottom">'. $case_date_string. '<hr />Date:</td>
         </tr>
      </table>   
   </td>
</tr>'; }


else {

echo '
<tr>
   <td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>
      <table border="0" width="100%">
         <tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>
         <tr>
            <td valign="bottom"><hr />Psychiatrist: '. $md_name_string. '</td>
            <td valign="bottom">'. $md_date_string. '<hr />Date:</td>
         </tr>
         <tr>
            <td valign="bottom"><hr />Case Manager: '. $case_manager_name_string. '</td>
            <td valign="bottom">'. $case_date_string. '<hr />Date:</td>
         </tr>
      </table>   
   </td>
</tr>'; }
}

 

HOWEVER...There is another issue. The signatures appear at the top and not the bottom. Anyone know why this is?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.