Jump to content

Arl8

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Arl8's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This form works: [color=red]displayrecord.php[/color] [code] <?php require_once('odbc.php'); $lname=$_REQUEST['LastName']; $fname=$_REQUEST['FirstName']; $dob=$_REQUEST['DOB']; $query = "SELECT * from tblPatient"; if ( $_POST['LastName'] != "") { $where[] = "LastName LIKE '%$lname%'"; } if ( $_POST['FirstName'] != ""){ $where[] = "FirstName LIKE '%$fname%'"; } if ($_POST['DOB'] != ""){ $where[] = "DOB LIKE '%$dob%'"; } if (count($where) > 0) { $query .= " WHERE " . implode(" AND ", $where); } $result = odbc_exec($odbc, $query) or die (odbc_errormsg()); $row = odbc_fetch_array($result); ?> <p> </p> <form name="displayrecord" method="post" action="updaterecord.php">   <table width="1000" border="1" align="center" cellpadding="2">     <tr>       <td colspan="8">         <div align="center"><b>Update Patient Information</b></div>       </td>     </tr> <tr> <td width="100"> <div align="right">LName </div> </td> <td width="150"> <input type="text" name="LastName" value="<? echo $row['LastName']; ?>"> </td> <td width="100"> <div align="right">FName</div> </td> <td width="150"> <input type="text" name="FirstName" value="<? echo $row['FirstName']; ?>"> </td> <td width="100"> <div align="right">Middle </div>   </td> <td width="150"> <input type="text" name="Middle" value="<? echo $row['Middle']; ?>">   </td> <td width="100"> <div align="right">Nickname </div>   </td> <td width="150"> <input type="text" name="NickName" value="<? echo $row['NickName']; ?>">   </td> </tr> [/code] and etc., the form continues. This is what my code is for the updating script, which returns nothing.  Any suggestions? [color=red]updaterecord.php[/color] [code] <?php require_once('odbc.php'); $lname=$_REQUEST['LastName']; $fname=$_REQUEST['FirstName']; $dob=$_REQUEST['DOB']; $hm=$_REQUEST['HM']; $wk=$_REQUEST['WK']; $er=$_REQUEST['ER']; $cell==$_REQUEST['CellPhone']; $ptid=$_REQUEST['PatientID']; $chartid=$_REQUEST['ChartID']; $acctnum=$_REQUEST['ACCTNUM']; $mid=$_REQUEST['Middle']; $race=$_REQUEST['Race']; $sex=$_REQUEST['Sex']; $nick=$_REQUEST['NickName']; $marital=$_REQUEST['Marital']; $zip=$_REQUEST['Zip']; $ins1=$_REQUEST['INS_NAME']; $ins2=$_REQUEST['Ins2Name']; $refdoc=$_REQUEST['REF_DOC']; $pmddoc=$_REQUEST['PMD_DOC']; $city=$_REQUEST['CITY']; $state=$_REQUEST['STATE']; $email1=$_REQUEST['EmailAddress']; $email2=$_REQUEST['EmailContact']; $occu=$_REQUEST['Occupation']; $employ=$_REQUEST['Employer']; $height=$_REQUEST['Height']; $weight=$_REQUEST['Weight']; $ssn=$_REQUEST['SSN']; $chartarch=$_REQUEST['ChartArchived']; $crdate=$_REQUEST['CrDate']; $cruser=$_REQUEST['CrUser']; $chdate=$_REQUEST['ChDate']; $chuser=$_REQUEST['ChUser']; $dead=$_REQUEST['Deceased']; $debt=$_REQUEST['BadDebt']; $chkacct=$_REQUEST['CheckAccount']; $needref=$_REQUEST['NeedsReferral']; $refsd=$_REQUEST['ReferralStartDate']; $refed=$_REQUEST['ReferralEndDate']; $refv=$_REQUEST['ReferralVisits']; $refn=$_REQUEST['ReferralNumber']; $visits=$_REQUEST['VisitsUsed']; $alltest=$_REQUEST['AllergyTest']; $allshot=$_REQUEST['AllergyShots']; $allmaint=$_REQUEST['AllergyMaint']; $allns=$_REQUEST['AllergyNeverStart']; $allquit=$_REQUEST['AllergyQuit']; $add1=$_REQUEST['ADDRESS1']; $add2=$_REQUEST['ADDRESS2']; $query="UPDATE tblPatient SET CITY='$city', ADDRESS1='$add1', STATE='$state', EmailAddress='$email1', EmailContact='$email2', Occupation='$occu', ADDRESS2='$add2', ReferralVisits='$refv', ReferralNumber='$refn', VisitsUsed='$visits', AllergyTest='$alltest', AllergyShots='$allshot', AllergyMaint='$allmaint', AllergyNeverStart='$allns', AllergyQuit='$allquit', NeedsReferral='$needred', ReferralStartDate='$refsd', ReferralEndDate='$refed', CrDate='$crdate', CrUser='$cruser', ChDate='$chdate', ChUser='$chuser', Deceased='$dead', Employer='$employ', Height='$height', Weight='$weight', SSN='$ssn', ChartArchived='$chartarch', CellPhone='$cell', ChartID='$chartid', PatientID='$ptid', ACCTNUM='$acctnum', Middle='$mid', Race='$race', Sex='$sex', NickName='$nick', Marital='$marital', Zip='$zip', INS_NAME='$ins1', Ins2Name='$ins2', BadDebt='$debt', CheckAccount='$chkacct',  REF_DOC='$refdoc', PMD_DOC='$pmddoc', HM='$hm', WK='$wk', ER='$er' WHERE LastName='$lname' AND FirstName='$fname' AND DOB='$dob'"; odbc_exec($odbc, $query); if (odbc_exec($odbc, $query)) {     echo odbc_affected_rows()." have been updated successfully"; } odbc_close(); ?> [/code] I'm confused.
  2. Clarifying, With the drop down menu added, if I do a query that returns only one record, no data is displayed.  If a query returns more than one record, they appear in the drop down menu, but selecting one does not populate the form with the record data.  Any input?
  3. Thanks for looking at it.  My problem arises in that script because after I press submit in the 2nd form, the DB has been updated.  The 3rd form, however, that should display the updated record and uses the odbc_affected_rows function leaves me with only a blank page.  Therefore, I think that it is the odbc_affected_rows function that is messing up my script, because the SQL works and the form works.  Any feedback is greatly appreciated.  Thanks again.
  4. Ok. I have the drop down menu on my screen now, but nothing shows in my form.  This is my code atm. [color=red]ptdisplay.php[/color] [code] <?php require_once('odbc.php'); $lname=$_REQUEST['LastName']; $fname=$_REQUEST['FirstName']; $dob=$_REQUEST['DOB']; $query = "SELECT * from tblPatient"; if ( $_POST['LastName'] != "") { $where[] = "LastName LIKE '%$lname%'"; } if ( $_POST['FirstName'] != ""){ $where[] = "FirstName LIKE '%$fname%'"; } if ($_POST['DOB'] != ""){ $where[] = "DOB LIKE '%$dob%'"; } if (count($where) > 0) { $query .= " WHERE " . implode(" AND ", $where); } $result = odbc_exec($odbc, $query) or die (odbc_errormsg()); if (odbc_num_rows($result) > 1) { //... form that submits to script that will pull the record for processing ... echo '<select name="selectname" size="1">'; while ($row = odbc_fetch_array($result)) { echo '<option value="' . $row['PatientID'] . '">' . $row['LastName'] . ', ' . $row['FirstName'] . ' - ' . $row['DOB'] . '</option>'; } echo '</select>'; } else { $row = odbc_fetch_array($result);             //...continue with previous script... } ?> <p> </p> <form name="ptdisplay" method="post">   <table width="1000" border="1" align="center" cellpadding="2">     <tr>       <td colspan="8">         <div align="center"><b>Patient Information</b></div>       </td>     </tr> <tr> <td width="100"> <div align="right">LName </div> </td> <td width="150"> <input type="text" name="LastName" value="<? echo $row['LastName']; ?>"> </td> ..... [/code] Form continues from there and ends.  When you said continue with previous script, does that mean I need to put the form construction, etc in the else statement under there?  Or do they need to be in both places?  Slightly confused, and thanks again.
  5. Hey ya'll, I'm having trouble finishing the last part of my edit/update records script for my database.  Currently I have a form that inputs 3 fields and queries the database by those three fields.  The second form takes the results from the query and displays all the information in the record.  This can be edited in the input fields of the form, and when finished I submit the data and it goes to my third script.  This script is where I am having trouble, specifically with the odbc_affected_rows() function.  Not sure if I need a converter or something, but i don't know what's going on and any feedback would be appreciated. [color=red]frmptupdate.php[/color]  ==> First form where input query data. [code] <p> </p> <form name="updateform" method="post" action="displayrecord.php">   <table width="250" border="0" align="center" cellpadding="3">     <tr>       <td colspan="2"> <center><b>Enter Patient Info</b></center>       </td>     </tr>     <tr >       <td width="100">         <center>Last Name</center>       </td>       <td width="150">         <input type="text" name="LastName">       </td>     </tr>     <tr >       <td width="100">         <center>First Name</center>       </td>       <td width="150">         <input type="text" name="FirstName">       </td>     </tr>     <tr >       <td width="100">         <center>DOB</center>       </td>       <td width="150">         <input type="text" name="DOB">       </td>     </tr>      <tr>       <td colspan="2" >         <center>           <input type="submit" name="Submit" value="Submit">         </center>       </td>     </tr> [/code] [color=red]displayrecord.php[/color]  ==> Pulls data from record specified by query, can edit all of the fields and press submit to send to next form. [code] <?php require_once('odbc.php'); $lname=$_REQUEST['LastName']; $fname=$_REQUEST['FirstName']; $dob=$_REQUEST['DOB']; $query = "SELECT * from tblPatient"; if ( $_POST['LastName'] != "") { $where[] = "LastName LIKE '%$lname%'"; } if ( $_POST['FirstName'] != ""){ $where[] = "FirstName LIKE '%$fname%'"; } if ($_POST['DOB'] != ""){ $where[] = "DOB LIKE '%$dob%'"; } if (count($where) > 0) { $query .= " WHERE " . implode(" AND ", $where); } $result = odbc_exec($odbc, $query) or die (odbc_errormsg()); $row = odbc_fetch_array($result); ?> <p> </p> <form name="displayrecord" method="post" action="updaterecord.php">   <table width="1000" border="1" align="center" cellpadding="2">     <tr>       <td colspan="8">         <div align="center"><b>Update Patient Information</b></div>       </td>     </tr> <tr> <td width="100"> <div align="right">WK </div> </td> <td width="150"> <input type="text" name="WK" value="<? echo $row['WK']; ?>"> </td> <td width="100"> <div align="right">HM</div> </td> <td width="150"> <input type="text" name="HM" value="<? echo $row['HM']; ?>"> </td> <td width="100"> <div align="right">ER</div> </td> <td width="150"> <input type="text" name="ER" value="<? echo $row['ER']; ?>"> </td> </tr> </table> </form> [/code] ****Form continues the same way, form works, shortened for clarity.  Three left are fields being changed.  [color=red]updaterecord.php[/color]  ==>  Problems arise, not sure of the best way to update my data.  This is what I have at the moment.  Ideally it will update only rows affected by chance, hence odbc_affected_rows() , but am having trouble with the function.  There are far more fields, but only showing 3 for clarity. [code] <?php require_once('odbc.php'); $hm=$_REQUEST['HM]; $wk=$_REQUEST['WK']; $er=$_REQUEST['ER']; $query='UPDATE tblPatient SET HM='$hm', WK='$wk', ER='$er'"; odbc_exec($odbc, $query); echo odbc_affected_rows()."have been updated successfully"; odbc_close(); ?> <p> </p>   <table border="0" align="center" cellspacing="1"     cellpadding="5" width="1000">     <tr>   <td colspan="8">   <center><b>"Record is updated successfully</b></center>   </td>   </tr> <tr> <td width="100"> <div align="right">HM Phone </div>   </td> <td width="150"> <input type="text" name="HM" value="<? echo $hm; ?>">   </td> <td width="100"> <div align="right">WK Phone </div>   </td> <td width="150"> <input type="text" name="WK" value="<? echo $wk; ?>">   </td> <td width="100"> <div align="right">ER Phone </div>   </td> <td width="150"> <input type="text" name="ER" value="<? echo $er; ?>">   </td> </tr> </table> </form> [/code] If anyone has any feedback or better way of doing this please let me know.  Also, if this is not a safe way to update my database, please let me know.  Thanks
  6. Thanks, i checked the input and it's the way it should be.  I also use this script with some small modifications to make an edit/update script as well. Quick question: If I query and more than one record satisfies the query, how would I write that into a drop down menu where I can select which record I want, then go to my ptdisplay.php ?  Thanks again for the help.
  7. Hey ya'll, I have been writing script that has a form with three input boxes, let's call them LName, FName, and DOB.  What i'm trying to figure out is a way to search by any combination of the three, but you don't necessarily have to use each field.  Like i'd like to be able to search by LName and DOB, or all three, or just LName and FName.  Here's the scripts I have so far, omitting form code to make this faster. [color=red]frmptinfo.php[/color] ==> Sets up first form, calls to second form, has 3 input fields, and works.  Just posting to be thorough. [code] <p> </p> <form name="ptform" method="post" action="ptdisplay.php">   <table width="250" border="0" align="center" cellpadding="3">     <tr>       <td colspan="2">         <center><b>Enter Patient Info</b></center>       </td>     </tr>     <tr >       <td width="100">         <center>Last Name</center>       </td>       <td width="150">         <input type="text" name="LastName">       </td>     </tr>     <tr >       <td width="100">         <center>First Name</center>       </td>       <td width="150">         <input type="text" name="FirstName">       </td>     </tr>     <tr >       <td width="100">         <center>DOB</center>       </td>       <td width="150">         <input type="text" name="DOB">       </td>     </tr>      <tr>       <td colspan="2" >         <center>           <input type="submit" name="Submit" value="Submit">         </center>       </td>     </tr> [/code] [color=red]ptdisplay.php[/color] ==> Here is where my problems arise, just going to post PHP/SQL jazz. [code] <?php require_once('odbc.php'); //$lname=$_REQUEST['LastName']; //$fname=$_REQUEST['FirstName']; //$dob=$_REQUEST['DOB']; if ($lname=null){ do_nothing();} else{ $lname=$_REQUEST['LastName'];} if ($fname=null){ do_nothing();} else{ $fname=$_REQUEST['FirstName'];} if ($dob=null){ do_nothing();} else{ $lname=$_REQUEST['DOB'];} $query="SELECT * from tblPatient WHERE LastName='$lname' AND FirstName='$fname' AND DOB='$dob'"; $result=odbc_exec($odbc, $query) or die (odbc_errormsg()); $row=odbc_fetch_array($result); ?> [/code] Also, how would I make it so that when I search I don't have to write out the entire last or first name, yet it would still find the correct record from my database.  It's possible that a search could pull up more than one patient, and if so is there a way I can send that to a drop down menu to choose which patient it is?  Thanks for the help
  8. Hey all, I am moderately familiar with PHP and have been using it for a couple years for various different things. Basic information about my system: PHP 5 MySQL 4.1 Apache Windows XP Pro I'm using PHP/MySQL for a web-based server and have an ODBC set up in my office.  I'm running into some problems using the ODBC code as opposed to the MySQL code in some scripts I have been writing.  **In my scripts I use an ODBC database converter found in a tutorial on phpfreaks here [url=http://www.phpfreaks.com/tutorials/61/2.php]http://www.phpfreaks.com/tutorials/61/2.php[/url] , contains connection string also.  Also using MySQL Query Builder for testing SQL syntax. What i'm attempting to do at this point is make 3 scripts that allow me to input data specific to a patient, call the rest of the patient's information from my database, and update the additional information.  This first script makes a form where I input information patients at the office, Patient ID in this case.  This works fine, and after this form the form posts to my next script, displayrecord.php.  After inputing data, the script should call the particular record and display the rest of the information **code to create the form that accepts the patient id and displays the record from the patient table [code] <p> </p> <form name="updateform" method="post" action="displayrecord.php">   <table width="250" border="0" align="center" cellpadding="3">     <tr>       <td colspan="2">         <center><b>Enter Patient ID</b></center>       </td>     </tr>     <tr >       <td width="100">         <center>Patient ID</center>       </td>       <td width="150">         <input type="text" name="ptid">       </td>     </tr>     <tr>       <td colspan="2" >         <center>           <input type="submit" name="Submit" value="Submit">         </center>       </td>     </tr> <? require_once(odbc.php); ?> [/code] **PHP script to display the record and accept the updates for the existing record**  I run into problems as soon as I call displayrecord.php, i'm pretty sure my SQL syntax is correct, but it could be a problem with the form construction.  The output will show the beginning of the form, but no other fields of the form.  I feel it doesn't work because of naming/calling the fields from the array for the form inputs.  Here is le code: [code] <p> </p><form name="displayrecord" method="post" action="updaterecord.php">   <table width="250" border="1" align="center" cellpadding="3">     <tr>       <td colspan="2">         <div align="center"><b>Update Patient Information</b></div>       </td>     </tr> <?php require_once('odbc.php'); $query="SELECT * from tblPatient WHERE PatientID='" .$PatientID ."'"; $varquery=odbc_exec($odbc, $query) or die (odbc_errormsg()); if($record=odbc_fetch_array($varquery)) {     echo "<tr> ";     echo " <td width=\"100\"> ";     echo " <div align=\"right\">Patient ID </div>";     echo " </td>";     echo " <td width=\"150\"> ";     echo " <input type=\"text\" name=\"PatientID\" value=\"".$record["PatientID"]."\">";     echo " </td>";     echo " </tr>";     echo "<tr> ";     echo " <td width=\"100\"> ";     echo " <div align=\"right\">LName </div>";     echo " </td>";     echo " <td width=\"150\"> ";     echo " <input type=\"text\" name=\"LastName\" value=\"".$record["LastName"]."\">";     echo " </td>";     echo " </tr>";     echo " <tr> ";     echo " <td width=\"100\"> ";     echo " <div align=\"right\">FName</div>";     echo " </td>";     echo " <td width=\"150\"> ";     echo " <input type=\"text\" name=\"FirstName\" value=\"".$record["FirstName"]."\">";     echo " </td>";     echo " </tr>";     echo " <tr> ";     echo " <td width=\"100\"> ";     echo " <div align=\"right\">Address </div>";     echo " </td>";     echo " <td width=\"150\"> ";     echo " <input type=\"text\" name=\"ADDRESS1\" value=\"".$record["ADDRESS1"]."\">";     echo " </td>";     echo " </tr>";     echo "<tr> ";     echo " <td width=\"100\"> ";     echo " <div align=\"right\">Phone </div>";     echo " </td>";     echo " <td width=\"150\"> ";     echo " <input type=\"text\" name=\"HM\" value=\"".$record["HM"]."\">";     echo " </td>";     echo " </tr>";     echo " <tr> ";     echo " <td colspan=\"2\"> ";     echo " <div align=\"center\"> ";     echo " <input type=\"submit\" name=\"Submit\" value=\"Submit\">";     echo " </div>";     echo " </td>";     echo "</tr>"; } ?>  [/code] This last script accepts the record entered by the end user and updates the record in the MySQL table.  [code] <?php require_once('odbc.php'); $query="UPDATE tblPatient SET ADDRESS1=\"". $ADDRESS1 . "\" , HM=\"".$HM."\" WHERE PatientID=\"".$PatientID."\""; $varquery=odbc_exec($odbc, $query); if (!$varquery) {     die(" Query execution failed!!!<br>"); } else {     echo "<table border=\"0\" align=\"center\" cellspacing=\"1\"     cellpadding=\"5\" width=\"300\">";     echo " <tr> ";     echo " <td colspan=\"2\"> ";     echo " <center><b>".odbc_affected_rows()."record is updated successfully</b></center>";     echo " </td>";     echo " </tr>";     echo " <tr> ";     echo " <td width=\"100\"> ";     echo " <div align=\"right\">Patient ID</div>";     echo " </td>";     echo " <td width=\"200\">".$PatientID. "</td>";     echo " </tr>";     echo " <tr> ";     echo " <td width=\"100\"> ";     echo " <div align=\"right\">Last Name</div>";     echo " </td>";     echo " <td width=\"200\">".$LastName. "</td>";     echo " </tr>";     echo " <tr> ";     echo " <td width=\"100\"> ";     echo " <div align=\"right\">First Name</div>";     echo " </td>";     echo " <td width=\"200\">".$FirstName. "</td>";     echo " </tr>";     echo " <tr> ";     echo " <td width=\"100\"> ";     echo " <div align=\"right\">Address</div>";     echo " </td>";     echo " <td width=\"200\">".$ADDRESS1. "</td>";     echo " </tr>";     echo " <tr> ";     echo " <td width=\"100\"> ";     echo " <div align=\"right\">Phone</div>";     echo " </td>";     echo " <td width=\"200\">".$HM. "</td>";     echo " </tr>";     echo " <tr> ";     echo " <td colspan=\"2\"> </td>";     echo " </tr>";     echo "</table>"; } ?> [/code] Any and all input is greatly appreciated.  If you feel I am doing something a really stupid way, please let me know. Adam
×
×
  • 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.