Jump to content

Recommended Posts

hello,
i have below code and i need to change the status to inactive when i press the delete button. it happens that when i use the code below, the status does not change at all. can anyone tell me where am having an error in the code?

<?php

session_start();

include_once("db_connect.php");

if(isset($_POST['delete']))
{
    $prod_id=$_POST['prod_id'];
    $prod_name=$_POST['prod_name'];
    $prod_brand=$_POST['prod_brand'];
    $prod_desc=$_POST['prod_desc'];
    $prod_w_c=$_POST['prod_w_c'];

        //updating the table

        $result=mysql_query("UPDATE tblproduct SET status='inactive' WHERE prod_id='".$prod_id."';");

        header("Location: del_updprod.php");
    }

?>
<?php

$prod_id = $_GET['prod_id'];

$result=mysql_query("SELECT * FROM tblproduct where prod_id = ".$prod_id." AND status = 'active'") or die(mysql_error());

?>
<html>
<title>Delete Product</title>
<body background="Images/contentbg.jpg">
<a href="del_updprod.php"><img src="Images/back button.png" width="100" /></a>
<br/><br/>
<form name="edit" method="post" action="del_prod.php">
<table align="center" border="0">
<?php
while($res=mysql_fetch_array($result))
{
    $prod_name=$res['prod_name'];
    $prod_brand=$res['prod_brand'];
    $prod_desc=$res['prod_desc'];
    $prod_w_c=$res['prod_w_c'];

?>
   <tr> 
    <td>Product Name</td>
    <td>
        <input type="text" name="prod_name" value = "<?php echo $prod_name;?>"> </td>
  </tr>
  <tr> 
    <td>Product Brand</td>
    <td>
        <input type="text" name="prod_brand" value = "<?php echo $prod_brand;?>">     </td>
  </tr>
  <tr> 
    <td>Product Description</td>
    <td>
        <textarea rows="5" cols="50" name="ret_city"><?php echo $prod_desc;?></textarea>  </td>
  </tr>
  <tr> 
    <td>Product Weight/Capacity</td>
    <td>
        <input type="text" name="prod_w_c" value = "<?php echo $prod_w_c;?>">     </td>
  </tr>
  <?php } ?> 
   <tr>
    <td><input type="submit" name="delete" value="Delete"></td>
  </tr>
</table>
</form>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/280574-status-not-changing-in-database-table/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.