Jump to content

IF statement or varible problem


will35010

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.