Jump to content

Recommended Posts

I'm having a problem with the if at the bottom of the script. The variable $current is set using a select box that has two options: ER & Lobby. The varible comes across ok, but the if always treats the varible as if it's set to lobby. What am I doing wrong? Thanks!

 

<?php

/**
* @author Will Morris
* @copyright 2009
*/
//code to receive post data and add it to the database

//POST data varible assignment
$lname = $_POST['lname'];
$fname = $_POST['fname'];
$mrn = time();
$room = $_POST['room'];
$pmd = $_POST['pmd'];
$current_status = "Waiting on Room";
$comment = $_POST['comment'];
$regtime = time();
$current = $_POST['current'];
$arrive = $_POST['arrive'];
$age = $_POST['age'];
$sex = $_POST['sex'];
$cc = $_POST['cc'];
$ccother = $_POST['ccother'];

//for testing
//echo "Varible Current .'$current'.";


require('../db.php');

//Query to insert patient data
$query = "INSERT INTO pt_status (PATIENT_LAST_NAME, PATIENT_FIRST_NAME, MRN, ER_ROOM_NUMBER, PMD, CURRENT_STATUS, COMMENT, REG_TIME, CURRENT_LOCATION, ARRIVE, AGE, SEX, CC, CCOTHER) VALUES ('$lname', '$fname', '$mrn', '$room', '$pmd', '$current_status', '$comment', '$regtime', '$current', '$arrive', '$age', '$sex', '$cc', '$ccother')";

//send query to database
mysqli_query($conn, $query) or die('Error: ' . mysql_error());

//logic to either assign patient to lobby or room
//if to assign pt to lobby
if($current = "Lobby") {
$sql = "INSERT INTO `TRAX2`.`lobby` (`MRN`, `TIMESTAMP`) VALUES ('$mrn', '$mrn');";
mysqli_query($conn, $sql);
//if to assign pt to room
} elseif($current = "ER") {
//test echo output
echo "ER Insert";
$sql = "INSERT INTO rooms ('STATUS', 'MRN') VALUES ('1', '$mrn') WHERE NAME = '$room'";
mysqli_query($conn, $sql);	
}	

echo "<a href='../index.php'>Home Page</a>";
?>

Link to comment
https://forums.phpfreaks.com/topic/183308-if-statement-or-varible-problem/
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.