help with code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kenny724
Forum Newbie
Posts: 7
Joined: Sun Jan 31, 2010 3:19 pm

help with code

Post by kenny724 »

Can someone help? I'm trying to learn and support php/sql database. Someone else programmed this. There is a patient whose form is not populating with the data from the older form, however the others are populating. What could cause this?

Also, there are several fields that have places for signatures. If the dr. signs it, how would all the other lines populate with the other signatures? Where would I need to look or what would I need to add? Thanks for any help.

Confused.

Here is the form code. There are several lines with the signatures. What needs to happen is when the md signs it, the other fields need to populate with the signatures. Can someone help with this? Thanks.

Code: Select all

<?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=\"\" />";
}

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 = "";
$approved_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\" />";
else*/
$psychiatrist_sig = "<br /><br /><br />";
}
else
{
$psychiatrist_sig = "<br /><br /><br />";
$psychiatrist_name_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\" />";
else*/
$therapist_sig = "<br /><br /><br />";
}
else
{
$therapist_sig = "<br /><br /><br />";
$therapist_name_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\" />";
else*/
$activity_therapist_sig = "<br /><br /><br />";
}
else
{
$activity_therapist_sig = "<br /><br /><br />";
$activity_therapist_name_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\" />";
else*/
$case_manager_sig = "<br /><br /><br />";
}
else
{
$case_manager_sig = "<br /><br /><br />";
$case_manager_name_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\" />";
else*/
$other_sig = "<br /><br /><br />";
}
else
{
$other_sig = "<br /><br /><br />";
$other_name_string="";
}

?>
Last edited by Benjamin on Thu Oct 06, 2011 8:25 pm, edited 1 time in total.
Reason: Added [syntax=php|sql|css|javascript] and/or [text] tags.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: help with code

Post by flying_circus »

You need help with basic syntax. I copy and pasted the code you posted into my PHP editor and it lit up like a christmas tree.

Since you came here looking for help (there is another forum where you can post for hire), I recommend you find a decent PHP editor that will help you find syntax errors. Personally, I use NuSphere's PhpED, but there are many free applications that will do the same thing. Komodo is a good example.

Give that a shot and see how far you can get. Let us know if you get stuck.
Post Reply