UK SEO ForumsCalendarContact Us
  #1  
Old 10-26-2009, 05:01 PM
chinchi86 chinchi86 is offline
SEO Baby
 
Join Date: Oct 2009
Posts: 2
iTrader: 0
chinchi86 is on a distinguished road
PHP/MySQL UPDATE and SET

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
__________________
Ayurveda Cure programs
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT +1. The time now is 11:52 PM.
vBSkinworks

UK SEO