Hello,
I'm trying to do a very basic page that allows me to edit a single column in a MSSQL database. For whatever reason I can't figure it out and am hoping that you can help.
Here is my front page (sorry about the silly names)
$ninja_conn = odbc_connect('XXXXX','XXXX','XXXX', SQL_CUR_USE_ODBC);
?>
<head>
<title>In/Out</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="upper_left"></div>
<div id="upper_right"></div>
<div id="lower_left"></div>
<div id="lower_right"></div>
<div id="page_wrap">
<h1>Time Clock Status</h1>
<br /><br />
<?php
$sql_ninja_stats = "SELECT * from dbo.TCNinja";
$ninja_get=odbc_exec($ninja_conn, $sql_ninja_stats);
echo'<table border="1">
<th><b><u>Name</b></u></th>
<th> </th>
<th><b><u>Status</b></u></th>
<th> </th>
<th><b><u>Update</b></u></th>';
while($rows=odbc_fetch_array($ninja_get)){
echo "
<tr>
<td>".$rows['EmpName']."</td>
<td> </td>
<td><select name='Status'>
<option value=".$rows['Status']." selected='selected'>". $rows['Status']."</option>
<option vlaue='1'>1</option>
<option vlaue='0'>0</option>
</select></td>
<td> </td>
<td><a href='tcninja_update.php?ID=".$rows['ID']."'>submit</a></td>
</tr>
";
}
echo'</table>';
?>
</form></div></body></html>
That pulls the data fine, but when I try to submit I'm getting undefined indexes.
Here is the back end page:
$ninja_conn = odbc_connect('XXXX','XXXXX','XXXX', SQL_CUR_USE_ODBC);
$status=$_POST['Status'];
$id=$_POST['ID'];
$query="UPDATE dbo.TCNinja SET Status='$status' WHERE ID='$id'";
/// Perform the update ///
$result=odbc_exec($ninja_conn, $query);
/// if successfully updated. ///
if($result){
header("Location:http://phi/who/tcninjas.php");
}
else {
echo "Error";
}
/// close connection ///
odbc_close($ninja_conn);
?>
Any suggestions?