Jump to content

[SOLVED] trying to populate fields with values from db...


rsammy

Recommended Posts

Hi,

I am trying to populate some fields on screen with values from db. i wrote the query and tested it out in MySQL and it works fine. it returns the necessary records. only, when i use the same query in my code, just the label names print on screen and no values for them.

here is the code... I am not sure where exactly the problem is, so am attaching the entire code for this page here.

<?PHP

//File for database information

//require_once ("phpInclude/config.php");
require_once ("../config.php");

//File to verify authenticated user

include ("phpInclude/cookie.php");



if (isset($USER_NAME))

{

list($user_fname, $user_lname) = explode (' ', $USER_NAME);

$pat_ID=$_POST["pat_ID"];
if ($USER_NAME == ' Office Manager')
{
$query= "SELECT grp_name FROM group_details";
}
else
{
$query= "SELECT grp_name FROM group_details, user_mgr WHERE user_mgr.user_fname='$user_fname' AND user_mgr.user_lname='$user_lname' AND user_mgr.user_grp_id=group_details.grp_id";
}
$result=mysql_query($query);

$row = mysql_fetch_array($result);

$group_name = $row["grp_name"];

}



?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>INSTICOMM</title>

<link rel='stylesheet' type='text/css' href='css/styleSheet.css'>



<SCRIPT language="JavaScript" src="js/tree.js"></script>

<SCRIPT language="JavaScript" src="js/validateSSN.js"></SCRIPT>

<SCRIPT language="JavaScript">

function trim(inputString)
{

  // Removes leading and trailing spaces from the passed string. Also

  // removes consecutive spaces and replaces it with one space.

  var retValue = inputString;

  var ch = retValue.substring(0, 1);

  while (ch == " ") { // Check for spaces at the beginning of the string

  retValue = retValue.substring(1, retValue.length);

  ch = retValue.substring(0, 1);

}

    ch = retValue.substring(retValue.length-1, retValue.length);

    while (ch == " ") { // Check for spaces at the end of the string

      retValue = retValue.substring(0, retValue.length-1);

      ch = retValue.substring(retValue.length-1, retValue.length);

}

  while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string

  retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings

}

return retValue; // Return the trimmed string back to the user

} // Ends the "trim" function

function validate()

{
var err_msg = new Array();

var i=0;

var j=0;

var bigstring = "Please correct the following errors:\n";

var loginID = "";

var pass = "";

var count = 0;

var aMatch = false;

var aBlank = false;



PatientFirstName = document.changeStatus.PatientFirstName.value;

PatientLastName = document.changeStatus.PatientLastName.value;
AdmitStatus = document.changeStatus.AdmitStatus.value;

AdmitLocation = document.changeStatus.AdmitLocation.value;

AdmitRoomNo = document.changeStatus.AdmitRoomNo.value;

PatientCity = document.changeStatus.PatientCity.value;

PatientState = document.changeStatus.PatientState.value;

PatientZip = document.changeStatus.PatientZip.value;

PatientHomePhone = document.changeStatus.PatientHomePhone.value;

PatientDOB = document.changeStatus.PatientDOB.value;

PatientSSN = document.changeStatus.PatientSSN.value;

PatientSex = document.changeStatus.PatientSex.value;

PatientEmergencyContactName= document.changeStatus.PatientEmergencyContactName.value;

PatientEmergencyPhone= document.changeStatus.PatientEmergencyPhone.value;

PatientEmployerPhone = document.changeStatus.PatientEmployerPhone.value;

InsuranceProvider = document.changeStatus.InsuranceProvider.value;

InsuranceID = document.changeStatus.InsuranceID.value;

PatientRelationship = document.changeStatus.PatientRelationship.value;

ClientName = document.changeStatus.ClientName.value;
}

</Script>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function changeCase(frmObj)
{
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;

//tmpStr = frmObj.value.toLowerCase();
tmpStr = frmObj.value;

strLen = tmpStr.length;
if (strLen > 0)
{
for (index = 0; index < strLen; index++)
{
if (index == 0)
{
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else
{
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1))
{
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
}
}
  }
}
frmObj.value = tmpStr;
}
//  End -->

</SCRIPT>

<SCRIPT language="JavaScript">

<?PHP

//Navigation File
require_once ("../nav.php");

?>

</SCRIPT>

<?

$query="

SELECT pat_dgraphics.pat_first_name, pat_dgraphics.pat_mid_init, pat_dgraphics.pat_last_name, pat_dgraphics.pat_home_ph, Date_Format(pat_dgraphics.pat_dob, '%m/%d/%Y') as pat_dob,

pat_dgraphics.pat_ssn, pat_dgraphics.pat_ID, pat_dgraphics.pat_phy_id, Date_Format(pat_dgraphics.pat_reg_date, '%m/%d/%Y') as enter_date, pat_dgraphics.pat_client_id, pat_ins_det.ins_pro,

pat_ins_det.ins_grp_id, Date_Format(admit_stat.admit_visit_date, '%m/%d/%Y') as activate_date, admit_stat.admit_reason, admit_stat.admit_visit_loc, admit_stat.admit_room_no

FROM pat_dgraphics, pat_ins_det, admit_stat where pat_ID='$pat_ID'

";
print ("$pat_ID");
$result=mysql_db_query("$database[dbname]", $query);

$r=mysql_fetch_array($result);

$pat_first_name=$r["pat_first_name"];

$pat_mid_init=$r["pat_mid_init"];

$pat_last_name=$r["pat_last_name"];

$pat_home_ph=$r["pat_home_ph"];

$pat_dob=$r["pat_dob"];

$pat_ssn=$r["pat_ssn"];

$pat_client_id=$r["pat_client_id"];

$pat_phy_id = $r["pat_phy_id"];

$ins_pro = $r["ins_pro"];

$admit_reason = $r["admit_reason"];

$admit_status = $r["admit_status"];
$admit_visit_loc = $r["admit_visit_loc"];
$admit_room_no = $r["admit_room_no"];
$activate_date = $r["$activate_date"];
$enter_date = $r["$enter_date"];



$query ="SELECT * FROM pat_ins_det where ins_pat_id='$pat_ID' ";
$result = mysql_query($query);
$row= mysql_fetch_array($result);
$ins_pro=$row["ins_pro"];
$ins_ref=$row["ins_ref"];
$ins_id=$row["ins_id"];
$ins_grp_id=$row["ins_grp_id"];

$clientquery="SELECT client_name FROM clients WHERE client_id = '$pat_client_id'";
$resultclient= mysql_query($clientquery);
$row=mysql_fetch_array($resultclient);
$client_name=$row["client_name"];


?>

</head>



<BODY onload="window.scroll(0,yoffset)">

<table width="900" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="4" bgcolor="#FFFFFF">
      <div align="left"><font color="#FFFFFF"></font></div>
      <div align="right"><font color="#FFFFFF"><img src="images/title_barom.jpg" width="900" height="49"></font></div></td>
  </tr>
  <tr>
    <td align="left" valign="top" width="276"> <table width="276" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td align="left" valign="top"><div align="center"><img src="../images/clear.gif" height="15" width="1"><font color="#006699"><img src="images/clear.gif" height="15" width="1"><b><?PHP print($group_name); ?><br>
              User: </b><?PHP print($USER_NAME); ?> </font></div></td>
        </tr>
        <tr>
          <td align="left" valign="top"> <SCRIPT language="JavaScript">

  tree.loadState()

  tree.display()

</SCRIPT> </td>
        </tr>
</table>
     
</td>
        </a><br>
        <br>
      </div>
      <table width="614" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#006699">
          <tr>
            <td bgcolor="#006699" width="475" height="19"> <div align="left"><b><font color="#FFFFFF">Existing
                Patient: Change Patient Information/Status</font></b> </div></td>
        </tr>
        <tr>
          <td> <table width="608" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td colspan="3"><img src="../images/clear.gif" width="1" height="15"></td>
              </tr>
              <tr>
                <td width="15">&nbsp;</td>
                <!--<td width="578" rowspan="3" align="left" valign="top"> <form name="EditPatInfo" method="post" action="UpdatedPatInfo.php" onSubmit="return validate()">-->
                <td width="578" rowspan="3" align="left" valign="top"> <form name="changeStatus" method="post" action="updatedStatus.php" onSubmit="return validate()">
                <p align="center"><br><b>EXISTING PATIENT INFORMATION</b> <br></p>
                    <table width="563" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="283"> <div align="right"><font class="inputLbl">
                            <input type="hidden" name="pat_ID" value="<? print ("$pat_ID"); ?>">
                            </font></div></td>
                        <td colspan="2">&nbsp;</td>
                      </tr>
                      <tr>
                        <td width="283"> <div align="right"><font class="inputLbl">&nbsp;&nbsp;
                            </font></div></td>
                        <td colspan="2">&nbsp;</td>
                      </tr>
                      <tr>
                        <td width="283"> <div align="right"><font class="inputLbl">First
                            Name: &nbsp;&nbsp; </font></div></td>
                        <td colspan="2"><font class="plnTxtBl" type="text" name="PatientFirstName"><? print ("$pat_first_name"); ?></font>
                        </td>
                      </tr>
                      <tr>
                        <td width="283"> <div align="right"><font class="inputLbl">Middle
                            Initial: &nbsp;&nbsp; </font></div></td>
                        <td colspan="2"><font class="plnTxtBl"><? print ("$pat_mid_init"); ?></font>
                        </td>
                      </tr>
                      <tr>
                        <td width="283"> <div align="right"><font class="inputLbl">Last
                            Name: &nbsp;&nbsp; </font></div></td>
                        <td colspan="2"><font class="plnTxtBl"><? print ("$pat_last_name"); ?></font>
                        </td>
                      </tr>
                      <tr>
    <td width="283"> <div align="right"><font class="inputLbl">Date
  of Birth as mm/dd/yyyy: &nbsp;&nbsp; </font></div></td>
    <td colspan="2"><font class="plnTxtBl"><? print ("$pat_dob"); ?></font>

<script language=javascript>

function validateBDay()
{
var BirthdayDay = document.EditPatInfo.PatientDOB.value;
var bDate = BirthdayDay.split("/");
var bMonth = bDate[0];
var bDay = bDate[1];
var bYear = bDate[2];

var BDate = new Date(bYear, (bMonth - 1), bDay);
var Today = new Date();
TodayDay = Today.getDate();
TodayMon = Today.getMonth()+1;
TodayYear = Today.getYear();
if (TodayYear < 2000) TodayYear += 1900;
//var sysdate = new Date();

if (BDate > Today)
alert("Birthday cannot be greater than today's date");
}

</script></td>
  </tr>
  <tr>
  <td width="283"> <div align="right"><font class="inputLbl">ASN/
  SSN as a 9-digit number: &nbsp;&nbsp; </font></div></td>
  <td colspan="2"><font class="plnTxtBl"><? print ("$pat_ssn"); ?></font>
  </td>
  <!--<td width="108"><font class="errTxt">
<? if (!is_numeric($pat_ssn)){ print ("Please assign a valid 9-digit numeric ASN/ SSN for this patient."); } ?>
</font></td> -->
                      </tr>
                      <tr>
<td width="283"> <div align="right"><font class="inputLbl">Home
Phone as 000-000-0000: &nbsp;&nbsp; </font></div></td>
<td colspan="2"><font class="plnTxtBl"><? print ("$pat_home_ph"); ?></font>
</td>
                      </tr>
                      <tr>
<td><div align="right"><font class="inputLbl">Insurance
Provider: &nbsp;&nbsp;</font></div></td>
<td colspan="2"><font class="plnTxtBl"><? print ("$ins_pro"); ?></font>
</td>
  </tr>
</table>
  <!--<tr>
                        <td width="283"> <div align="right"><font class="inputLbl">Employer
                            Name: &nbsp;&nbsp; </font></div></td>
                        <td colspan="2"> <input class="txtboxLarge" type="text" name="PatientEmployer" value="<? print("$pat_emp"); ?>"  onBlur="javascript:changeCase(document.EditPatInfo.PatientEmployer);">
                        </td>
                      </tr>
                      <tr>
                        <td width="283"> <div align="right"><font class="inputLbl">Occupation:
                            &nbsp;&nbsp; </font></div></td>
                        <td colspan="2"> <input class="txtboxLarge" type="text" name="PatientOccupation" value="<? print("$pat_occ"); ?>"  onBlur="javascript:changeCase(document.EditPatInfo.PatientOccupation);">
                        </td>
                      </tr>
                      <tr>
                        <td><div align="right"><font class="inputLbl">Employer
                            Phone as 000-000-0000: &nbsp;&nbsp; </font></div></td>
                        <td colspan="2"><input class="txtboxLarge" type="text" name="PatientEmployerPhone" value="<? print("$pat_emp_ph"); ?>" ></td>
                      </tr> -->
                      <p align="center"><b>STATUS INFORMATION</b> <br></p>
<table width="562" border="0" cellspacing="0" cellpadding="0">
                      <tr>
  <td> <div align="right"><font class="inputLbl">Reason:&nbsp;&nbsp;</font></div></td>
  <td colspan="2"> <input name="reason" type="text" class="txtboxLarge" value="<? if(isset($admit_reason)){print ("$admit_reason"); } ?>" >
<span class="errTxt"> </span></td>
                      </tr>

                      <tr>
<td width="283"> <div align="right"><font class="inputLbl">Preferred
Provider:&nbsp;&nbsp;</font></div></td>
<td colspan="2">
<?PHP

//$query="select phy_id, phy_fname, phy_lname from phy_det order by phy_lname, phy_fname";
$query="select phy_id, phy_fname, phy_lname from phy_det where phy_disabled = 'Enable' order by phy_lname, phy_fname";

$result= mysql_query ($query);

if ($result)
{
print ("<select name='physician'>");

if ($row = mysql_fetch_array($result))
  {
  do
    {
    print("<option value=\"");
    print $row["phy_id"];
if($pat_phy_id == $row["phy_id"])
{
print("\" selected>");
}
else
{
  print("\">");
}
    //print $row["phy_fname"]; print (" "); print $row["phy_lname"];
    print $row["phy_lname"]; print (", "); print $row["phy_fname"];
      print("</option>");
  }
  while($row = mysql_fetch_array($result));
  }
  }
            print ("</select>");
?>
    </td>
  </tr>
      <tr>
    <td><div align="right"><font class="inputLbl">Registered
        Client: &nbsp;</font> </div></td>
    <td colspan="2"><? $queryclient="SELECT client_name, client_id FROM clients";
    $resultclient= mysql_query($queryclient);

  if ($resultclient)
  //if (mysql_num_rows($resultclient) != 0)
    {
//print ("<select name='client_id'>");
print ("<select name='ClientName'>");
//echo "$row";
if ($row = mysql_fetch_array($resultclient))
  {
    do
  {

print("<option value=\"");
echo $row["client_name"];
if ($row["client_name"]== $client_name)
{
print("\" selected>");
}
else
{
print("\">");
  }
print $row["client_name"];
print("</option>");
    //}
  }

    while($row = mysql_fetch_array($resultclient));
  }
  }
            print ("</select>");
  //}
  ?></td>
                      </tr>
                      <tr>
                        <td><div align="right"><font class="inputLbl">Insurance
                            Ref #: &nbsp;&nbsp;</font></div></td>
                        <td colspan="2"><input name="ins_ref" type="text" class="txtboxLarge" id="ins_ref"  onBlur="javascript:changeCase(document.EditPatInfo.InsuranceProvider);" value="<? print("$ins_ref"); ?>"></td>
                      </tr>-->

                      <tr>
<td width="282"> <div align="right"><font class="inputLbl">Status: &nbsp;&nbsp; </font></div></td>
<td colspan="2"><input class="txtboxLarge" type="text" name="AdmitStatus" value="<? print ("$admit_status"); ?>">
</td>
                      </tr>
                      <tr>
                        <td width="282"> <div align="right"><font class="inputLbl">Location: &nbsp;&nbsp; </font></div></td>
                        <td colspan="2"><input class="txtboxLarge" type="text" name="AdmitLocation" value="<? print ("$admit_visit_loc"); ?>">
                        </td>
                      </tr>
                      <tr>
                        <td width="282"> <div align="right"><font class="inputLbl">Room#: &nbsp;&nbsp; </font></div></td>
                        <td colspan="2"><input class="txtboxLarge" type="text" name="AdmitRoomNo" value="<? print ("$admit_room_no "); ?>">
                        </td>
                      </tr>
  <tr>
<td width="278"> <div align="right"><font class="inputLbl">Enter Date:&nbsp; &nbsp; </font></div></td>
<td colspan="2"><font class="plnTxtBl"><? print ("$enter_date"); ?></font></td>
  </tr>
  <tr>
<td width="278"> <div align="right"><font class="inputLbl">Activate Date:&nbsp; &nbsp; </font></div></td>
<td colspan="2"><font class="plnTxtBl"><? print ("$activate_date"); ?></font></td>
                    </tr>
                      <tr>
                        <td width="282"> <div align="right"></div></td>
                        <td width="280">&nbsp;</td>
                      </tr>

                      <tr>
                        <td width="282"> <div align="right"></div></td>
                        <td width="280"> <input class="sbttn" type="submit" name="Submit" value="Update">
                        </td>
                      </tr>
                      <tr>
                        <td width="282"> <div align="right"></div></td>
                        <td width="280">&nbsp;</td>
                      </tr>
                    </table>
                  </form>
                  <p align="center">&nbsp;</p>
                  <p align="center">&nbsp;</p></td>
                <td width="15">&nbsp;</td>
              </tr>
              <tr>
                <td width="15">&nbsp;</td>
                <td width="15">&nbsp;</td>
              </tr>
              <tr>
                <td width="15" height="478"><img src="../images/clear.gif" width="15" height="8"></td>
                <td width="15" height="478"><img src="../images/clear.gif" width="15" height="1"></td>
              </tr>
              <tr>
                <td colspan="3"><img src="../images/clear.gif" width="1" height="15"></td>
              </tr>
            </table></td>
        </tr>
      </table>
      <p>&nbsp;</p></td>
  </tr>
  <tr>
    <td align="left" valign="top" width="276"> </td>
    <td colspan="3" width="624">&nbsp;</td>
  </tr>
</table>



</body>

</html>

<?PHP

mysql_close();

?>


****************************

can someone help me out with this one please?

thanx in advance


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.