I was wondering if someone could point me on the right path here. There's a database with fields: PersonID
, FirstName
, LastName
, isActive
.
I collect those values from a form:
<form action="" method="POST" id="myForm"><input type="hidden" name="hdnId" id="hdnId" value="<?php echo $var_PersonID?>">
First Name<br>
<input type="text" name="txt_first_name" id="txt_first_name" value="<?php echo $var_FirstName;?>">
Last Name<br>
<input type="text" name="txt_last_name" id="txt_last_name" value="<?php echo $var_LastName;?>">
Status <br>
<select name="status" id="status">
<option value="" > </option>
<option value="1" >Active</option>
<option value="2" >Inactive</option>
</select>
</form>
The PHP code when submit the form looks like this:
<?php
if(isset($_POST['Save']) || isset($_POST['Saveexit']))
{
$var_PersonID = $_POST['hdnId'];
$var_FirstName = $_POST['txt_first_name'];
$var_LastName = $_POST['txt_last_name'];
$var_IsActive = $_POST['status'];
if($var_PersonID!='')
{
$sql = "UPDATE vw_Persons SET FirstName, LastName, isActive = ? WHERE PersonID = $var_PersonID ";
$params = array($var_FirstName, $var_LastName,$var_IsActive);
$stmt = sqlsrv_query( $gaSql['link'], $sql, $params);
}
} ?>
Once the page is loaded I grab values like this:
enter code here
<?php
if(isset($_GET['id']))
{
$query = "SELECT * FROM vw_Persons WHERE PersonID = '" . $_GET['id'] . "'";
$result = sqlsrv_query($gaSql['link'], $query) or die("<pre>" . print_r(sqlsrv_errors()) . "<br><br>$query</pre>");
$obj = sqlsrv_fetch_object( $result );
$var_PersonID = $obj->PersonID;
$var_LastName = $obj->LastName;
$var_FirstName = $obj->FirstName;
$var_IsActive = $obj->isActive;
} ?>
So the query updates the FirstName
and Last Name
values but no the isActive
value, why would this happen?