Jump to content
#StayAtHome ×


New Members
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About samanj

  • Rank
  1. Final update, I have made what I wanted to work, work. One page for everything. Case closed. If anyone is interested in the code (albeit a very simple one), then feel free to get in touch
  2. Ok thank you for the replies, it got the mental circuits in the brain working! This is what I have been able to find and tweak based on both of your guidances (work in progress for all of the rows needed): <!DOCTYPE html> <html> <head> <title>Specialty Referral Form</title> <style> table { width: 100%; color: #000000; font-family: arial; font-size: 10px; text-align: center; } th { background-color: #588c7e; color: white; } tr:nth-child(even) {background-color: #f2f2f2} </style> </head> <body> <table> </tr> <?php $link = mysqli_connect("localhost", "root", "", "referral"); if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } $sql = "SELECT * FROM referralcard WHERE hospitalnumber='345678'"; if($res = mysqli_query($link, $sql)){ if(mysqli_num_rows($res) > 0){ echo "<table>"; echo "<tr>"; echo "<th>patientdetails</th>"; echo "<th>hospitalnumber</th>"; echo "<th>history</th>"; echo "<th>comments</th>"; echo "</tr>"; while($row = mysqli_fetch_array($res)){ echo "<tr>"; echo "<td>" . $row['patientdetails'] . "</td>"; echo "<td>" . $row['hospitalnumber'] . "</td>"; echo "<td>" . $row['history'] . "</td>"; echo "<td>" . $row['comments'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_free_result($res); } else{ echo "No Matching records are found."; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } mysqli_close($link); ?> I appreciate you want propose that I make one file for all the different specialties. My question is probably even more specific now, but any advice on how I can tailor this part: $sql = "SELECT * FROM referralcard WHERE hospitalnumber='345678'"; i.e. the hospital number, in a text box, where I can type the number I want and that number appear as the hospital number I want where '345678' is currently in the code. Then press submit to have the single row result I am looking for. Would this be more in the realm of merging a html text box with php coding (e.g. is it using the POST function?) Hope this makes sense. Thanks as always.
  3. Hello community, I am working on a database of specialties in the hospital I work. The doctor's referral requests are sent to a mySQL database and I have, with the help of online guidance, produced a working php script that displays the information I need it to. However, I need it a little bit more specific. I intend to make multiple copies of this file for each specialty, so that when they open the file they only have the requests for that particular specialty. My question is, with reference to my code below, can I make echo information so that online, for instance, if 'specialty1 = gastroenterology' (as in, that particular specialty that that referral request is for), then only the rows on the database that have that particular text are displayed only? Hope that makes sense. Code below for your reference and assistance is highly appreciated. <!DOCTYPE html> <html> <head> <title>Specialty Referral Form</title> <style> table { border-collapse: collapse; width: 100%; color: #000000; font-family: arial; font-size: 10px; text-align: center; } th { background-color: #588c7e; color: white; } tr:nth-child(even) {background-color: #f2f2f2} </style> </head> <body> <table> <tr> <th>Patient Details</th> <th>Hospital Number</th> <th>Date of Birth</th> <th>Referred by:</th> <th>New/Repeat Visit to Patient</th> <th>Specialty</th> <th>Admission Date</th> <th>Too Ill for Clinic?</th> <th>Diagnosis Aware?</th> <th>Question</th> <th>History</th> <th>Medications</th> <th>Examination</th> <th>Results</th> <th>WorkingDiagnosis</th> <th>Investigation(s) Requested</th> </tr> <?php $conn = mysqli_connect("localhost", "view", "", "referral"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT patientdetails, hospitalnumber, DoB, referral, admission, specialty1, admissiondate, illness, awareness, question, history, medications, examination, results, workingdiagnosis, investigations FROM referralform"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while ($row = $result->fetch_assoc()) { echo "<tr><td>" . $row["patientdetails"]. "</td><td>" . $row["hospitalnumber"] . "</td><td>" . $row["DoB"] . "</td><td>" . $row["referral"] . "</td><td>" . $row["admission"] . "</td><td>" . $row["specialty1"] . "</td><td>" . $row["admissiondate"] . "</td><td>" . $row["illness"] . "</td><td>" . $row["awareness"] . "</td><td>" . $row["question"] . "</td><td>" . $row["history"] . "</td><td>" . $row["medications"] . "</td><td>" . $row["examination"] . "</td><td>" . $row["results"] . "</td><td>" . $row["workingdiagnosis"] . "</td><td>" . $row["investigations"]. "</td></tr>"; } echo "</table>"; } else { echo "0 results"; } $conn->close(); ?> </table> </body> </html> I guess what I am looking for is something like echo specialty1 IF it writes a particular specialty and only that specialty. Thank you.
  4. Update on this, I started from scratch and worked bit by bit and finally got it to work 👍 Thanks for the feedback.
  5. Latest update: have seemed to get this far: Does this mean my password is incorrect? (Update: password is correct) Maybe I am almost there...
  6. Thanks, I have removed the pipe from every line, including the one you have shown. Now I am getting this when I submit: Am I getting closer? I am not very savvy in understanding what the SELECT query does, more just following the video. I do expect to look for everything in the table when I submit the form and then check the database using PhPMyAdmin
  7. Hi all, I have made some code based on following online youtube video for making a HTML form send to mySQL database via PHP: https://youtu.be/qm4Eih_2p-M The form I am making is hopefully going to help in the Hospital at which I work to speed patient referrals, so I am very keen on making it work. I have made the HTML form and the database, which I do not think are the problem. When I click 'Submit' on my HTML form, then my php file comes up with all the code written, rather than the message: "New referral sent succesfully". Additionally, when I check the database via 'MyPHPAdmin' there is no data added to the database I have made. I have been using Sublime and have spotted some mistakes here and there, but is there something glaringly obvious that I am doing wrong in my code that is stopping my form being sent to the database? Thank you, Saman <?php $patientname = | $_POST['patientname']; $hospitalnumber = | $_POST['hospitalnumber']; $DoB = | $_POST['DoB']; $specialty = | $_POST['specialty']; $otherspecialty = | $_POST['otherspecialty']; $admissiondate = | $_POST['admissiondate']; $referring = | $_POST['referring']; $bleep = | $_POST['bleep']; $Admission = | $_POST['Admission']; $Illness = | $_POST['Illness']; $Awareness = | $_POST['Awareness']; $question = | $_POST['question']; $history = | $_POST['history']; $medications = | $_POST['medications']; $examination = | $_POST['examination']; $results = | $_POST['results']; $diagnosis = | $_POST['diagnosis']; $investigations = | $_POST['investigations']; $host = "localhost" $dbUsername = "root"; $dbPassword = "xyzabc"; $dbname = "GreenCard"; $conn = new mysqli($host, $dbUsername, $dbPassword, $dbname); if (mysqli_connect_error()) { die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error()); } else { $INSERT = "INSERT Into Greencard (patientname, hospitalnumber, DoB, specialty, otherspecialty, admissiondate, referring, bleep, Admission, Illness, Awareness, question, history, medications, examination, results, diagnosis, investigations) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; //Prepare statement $stmt = $conn->prepare($INSERT); $stmt->bind_param("sisissssssssssssss", $patientname, $hospitalnumber, $DoB, $specialty, $otherspecialty, $admissiondate, $referring, $bleep, $Admission, $Illness, $Awareness, $question, $history, $medications, $examination, $results, $diagnosis, $investigations); $stmt->execute(); echo "New referral sent successfully"; } $stmt->close(); $conn->close(); } else { echo "Make sure fields are completed"; die(); } ?>
  • 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.