Technology, Web & Business Forum

You are here: Technology, Web & Business Forum : Web Development : Programming : PHP/MySQL UPDATE and SET


Welcome to the Technology, Web & Business Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.


Programming Discuss programming languages such as .NET, PHP, PERL, ASP, ColdFusion, C++


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-26-2009
Junior Member
 
Join Date: Oct 2009
Posts: 3
Default 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
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 07:12 PM.