Hello,

I'm trying to make a script so I can select a "unit" and change it's status to either "available" or "unavailable". I just can't seem to get it to work though.

Here is what I'm currently using:

PHP Code:
<?php
        
// Display Units
        
$resultIncident mysql_query("SELECT * FROM units");

echo 
"<table border='1'>
<tr>
<th>Unit ID</th>
<th>Unit Status</th>
<th>District</th>
<th>Change Status</th>
</tr>"
;

while(
$row mysql_fetch_array($resultIncident))
  {
  echo 
"<tr>";
  echo 
"<td>" $row['id'] . "</td>";
  echo 
"<td>" $row['status'] . "</td>";
  echo 
"<td>" $row['district'] . "</td>";
  
//make the title a link
  
echo "<input type='hidden' name='pin' value='$row[id]'/>";
  echo 
"<td><input type='submit' class='deleteButton' name='unitStatusN' value='Delete Incident'/></td>";
  echo 
"</tr>";
  }
echo 
"</table>";

        
?>
<?php
// Unit Status (Available)
/*
if ($_POST['statusAvailable']){
    $uid = $_POST['id'];
    $queryUnit = mysql_query("UPDATE units SET status='Available' WHERE id='$uid'")or die(mysql_error());
}
// Unit Status (Unavailable)
if ($_POST['statusUnavailable']){
    $uid = $_POST['id'];
    $queryUnit = mysql_query("UPDATE units SET status='Unavailable' WHERE id='$uid'")or die(mysql_error());
}
*/
//Change Unit Status
if ($_POST['unitStatusN']) {
    
$unitID $_POST['id'];
    
$unitQuery mysql_query("UPDATE units SET status='unavailable' WHERE id='$unitID'")or die(mysql_error());
    
$resultUnit mysql_query($query);
}

// Delete Incident
//If cmd has not been initialized
if(!isset($status)) 
{
   
//display all the news
   
$resultUnit mysql_query("select * from units order by id"); 
   
   
//run the while loop that grabs all the news scripts
   
while($r=mysql_fetch_array($resultUnit)) 
   { 
      
//grab the title and the ID of the news
      
$idUnit=$r["id"];//take out the id
    
}


$statusN "Unavailable";
?>
If anyone can help me with this, I'd be very grateful.

Thanks