I don't know how to convert this $_POST to string and ASSIGN it to a variale rather than an array. Is there a Convert.ToString(RadioButtonValue) like in C#? I want to use the variable as a parameter in my SQL statement.
$DeptCode = $_POST['Department'];
print_r($DeptCode);
$sql = "SELECT EMPLOYEE.EmpID, EmpName FROM EMPLOYEE, EMPLOYEE_SPECIALIZATION WHERE EMPLOYEE.EmpID = EMPLOYEE_SPECIALIZATION.EmpID AND EmpStatus='active' AND DeptCode = '$DeptCode'";
$results = mysql_query($sql,$con);
if($results != $sql)
{
die('Error' . mysql_error());
}
This is my SQL statement. What am I doing wrong?
$sql = "SELECT EMPLOYEE.EmpID, EmpName FROM EMPLOYEE, EMPLOYEE_SPECIALIZATION WHERE EMPLOYEE.EmpID = EMPLOYEE_SPECIALIZATION.EmpID AND EmpStatus='active' AND DeptCode = '$DeptCode'";
When I run it... it always show
Array ( [0] => PD ) Error
This is the whole code:
<html>
<head>
<title>New Checkup</title>
</head>
<body>
<h1><a href="http://localhost/clinic/InsertPatient.php">Insert Patient</a></h1><br>
<h1><a href="http://localhost/clinic/InsertEmployee.php">Insert Doctor and Specialization</a></h1>
<h1><a href="http://localhost/clinic/InsertProcedureHTML.php">Insert Products and Services</a></h1>
<h1><a href="http://localhost/clinic/NewCheckup.php">New Checkup</a></h1>
<form method="post">
<?php
//action="http://localhost/clinic/NewCheckup2.php"
$con = mysql_connect('localhost', 'root', "");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_clinic", $con) or die(mysql_error());
$sql = "SELECT DeptCode, DeptName FROM DEPARTMENT";
$results = mysql_query($sql,$con);
while($row=mysql_fetch_assoc($results))
{
echo "<input type='radio' name='Department[]' value='".$row['DeptCode']."'>".$row['DeptName'];
}
mysql_close($con);
?>
<input type="submit" name="btnSubmit">
</form>
<?php
if(isset($_POST['btnSubmit']))
{
$con = mysql_connect('localhost', 'root', "");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_clinic", $con) or die(mysql_error());
$DeptCode = $_POST['Department'];
print_r($DeptCode);
echo $DeptCode;
$sql = "SELECT EMPLOYEE.EmpID, EmpName FROM EMPLOYEE, EMPLOYEE_SPECIALIZATION WHERE EMPLOYEE.EmpID = EMPLOYEE_SPECIALIZATION.EmpID AND EmpStatus='active' AND DeptCode = '$DeptCode'";
$results = mysql_query($sql,$con);
if($results != $sql)
{
die('Error' . mysql_error());
}
mysql_close($con);
}
?>
</body>