2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by mariaceline_21
0
// type determine 
    if($_REQUEST[style_type]=="Clothes")
        {
        $type = "Clothes";
        }
        else if($_REQUEST[style_type]=="Skincare")
        {
        $type = "Skincare";
        }
        else if($_REQUEST[style_type]=="Accessories")
        {
        $type = "Acccessories";
        }
        else
        {
        $type = "Select From Categories";
        }

    // get data 
    $id= $_POST[id];
    $name = $_POST[name];
    $product_qty = $_POST[product_qty];
    $price = $_POST[price];
    $description = $_POST[description];

    $st_id=$_REQUEST[index]."-".$_REQUEST[product_category];

    //add data
    if ($_POST[Submit]==Add){
         $search = mysql_query("SELECT id FROM shop WHERE name='$name' && product_category='$_REQUEST[product_category]' " ); 


    if(mysql_fetch_array($search)==0)
                   { 
                    // Image Load 

                          $st_id_img=$id.".png";
                          $sfile = $_FILES['img']['tmp_name']; 
                           $dfile = "img/products/".$st_id_img; 
                            copy($sfile, $dfile);


            $sql= "INSERT INTO shop(id, img, name, description, price, product_qty, product_category)      
                   VALUES('$st_id','$dfile','$name', '$descrition','$price' '$product_qty','$_REQUEST[product_category]' )";
                   if (!mysql_query($sql, $con)){die('Error: ' . mysql_error());}
                            else
                           $msg= "Record is added Successfully";
                   }
                   else


                          $msg= "Record is Already Exist";
         }
    if ($_POST[Submit]=="Update")
   {

       // Image Load 

                          $st_id_img=$st_id.".png";
                          $sfile = $_FILES['img']['tmp_name']; 
                           $dfile = "img/products/".$st_id_img; 
                            copy($sfile, $dfile);


    $sql = "UPDATE tb_style SET name='$_REQUEST[name]', 
                                product_qty='$_REQUEST[style_qty]', 
                                description='$_REQUEST[description]', 
                                price='$_REQUEST[price]',
                                img='$dfile'  
                                WHERE id ='$_REQUEST[id]' ";
                                    if (!mysql_query($sql, $con))
                                                  { die('Error: ' . mysql_error());}
                                           else $msg= "Record is Updated Successfully";
  }          


if ($_POST[Submit]=="Delete")
   {
    $st_id_img=$_REQUEST[id].".png";
   unlink($image);

    $sql = "Delete from shop WHERE id ='$_REQUEST[id]' ";
                                    if (!mysql_query($sql, $con))
                                                  { die('Error: ' . mysql_error());}
                                           else $msg= "Record is Delete Successfully";
  }                                        








$cc= mysql_query("Select *from  shop",$con); //check how many records exists in the database
  $count_mem=mysql_num_rows($cc);

   if ($count_mem==0)
    { 
    $index=1;


    }
    else
      { 
       $index=$count_mem+1;

      }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.