• 04-03-2023, 11:26:59
    #1
    Merhaba Arkadaşlar,
    Satış Ekle bölümünden ekledikten sonra satışlara gelen veriyi edit_sale yani satışı düzenle diyip girilen veri düzelttiğimde boş olamaz diye uyarı ile karşılaşıyorum kodumda nerede hata var yardımcı olur musunuz.

    <?php
      $page_title = 'Satış Düzenle';
      require_once('includes/load.php');
      // Checkin What level user has permission to view this page
       page_require_level(3);
    ?>
    <?php
    $sale = find_by_id('sales',(int)$_GET['id']);
    if(!$sale){
      $session->msg("d","Missing product id.");
      redirect('sales.php');
    }
    ?>
    <?php $product = find_by_id('products',$sale['product_id']); ?>
    <?php
    
      if(isset($_POST['update_sale'])){
        $req_fields = array('title','quantity','price','total', 'date', 'must' );
        validate_fields($req_fields);
            if(empty($errors)){
              $p_id      = $db->escape((int)$product['id']);
              $s_qty     = $db->escape((int)$_POST['quantity']);
              $s_total   = $db->escape($_POST['total']);
              $date      = $db->escape($_POST['date']);
               $must   = $db->escape($_POST['must']);
              $s_date    = date("Y-m-d", strtotime($date));
    
              $sql  = "UPDATE sales SET";
              $sql .= " product_id= '{$p_id}',qty={$s_qty},price='{$s_total}',date='{$s_date}'must='{$s_must}'";
              $sql .= " WHERE id ='{$sale['id']}'";
              $result = $db->query($sql);
              if( $result && $db->affected_rows() === 1){
                        update_product_qty($s_qty,$p_id);
                        $session->msg('s',"Satış Güncellendi.");
                        redirect('edit_sale.php?id='.$sale['id'], false);
                      } else {
                        $session->msg('d',' Sorry failed to updated!');
                        redirect('sales.php', false);
                      }
            } else {
               $session->msg("d", $errors);
               redirect('edit_sale.php?id='.(int)$sale['id'],false);
            }
      }
    
    ?>
    <?php include_once('layouts/header.php'); ?>
    <div class="row">
      <div class="col-md-6">
        <?php echo display_msg($msg); ?>
      </div>
    </div>
    <div class="row">
    
      <div class="col-md-12">
      <div class="panel">
        <div class="panel-heading clearfix">
          <strong>
            <span class="glyphicon glyphicon-th"></span>
            <span>Satışlar</span>
         </strong>
         <div class="pull-right">
           <a href="sales.php" class="btn btn-primary">Bütün Satışları Göster</a>
         </div>
        </div>
        <div class="panel-body">
           <table class="table table-bordered">
             <thead>
              <th> Ürün Adı</th>
              <th> Müşteri Adı </th>
              <th> Adet </th>
              <th> Fiyat </th>
              <th> Toplam </th>
              <th> Tarih</th>
              <th> Aksiyon</th>
             </thead>
               <tbody  id="product_info">
                  <tr>
                  <form method="post" action="edit_sale.php?id=<?php echo (int)$sale['id']; ?>">
                    <td id="s_name">
                      <input type="text" class="form-control" id="sug_input" name="title" value="<?php echo remove_junk($product['name']); ?>">
                      <div id="result" class="list-group"></div>
                    </td>
                     <td id="s_must">
                      <input type="text" class="form-control" id="sug_input" name="title" value="<?php echo remove_junk($sale['must']); ?>">
                    </td>
                    <td id="s_qty">
                      <input type="text" class="form-control" name="quantity" value="<?php echo (int)$sale['qty']; ?>">
                    </td>
                    <td id="s_price">
                      <input type="text" class="form-control" name="price" value="<?php echo remove_junk($product['sale_price']); ?>" >
                    </td>
                    <td>
                      <input type="text" class="form-control" name="total" value="<?php echo remove_junk($sale['price']); ?>">
                    </td>
                    <td id="s_date">
                      <input type="date" class="form-control datepicker" name="date" data-date-format="" value="<?php echo remove_junk($sale['date']); ?>">
                    </td>
                    <td>
                      <button type="submit" name="update_sale" class="btn btn-primary">Satışı Güncelle</button>
                    </td>
                  </form>
                  </tr>
               </tbody>
           </table>
    
        </div>
      </div>
      </div>
    
    </div>
    
    <?php include_once('layouts/footer.php'); ?>
  • 04-03-2023, 11:32:47
    #2
    burada 2 tane name=title kullanmışsınız ondan yapıyordur.
      <input type="text" class="form-control" id="sug_input" name="title" value="<?php echo remove_junk($product['name']); ?>">
                      <div id="result" class="list-group"></div>
                    </td>
                     <td id="s_must">
                      <input type="text" class="form-control" id="sug_input" name="title" value="<?php echo remove_junk($sale['must']); ?>">
  • 04-03-2023, 11:50:34
    #3
    ntka adlı üyeden alıntı: mesajı görüntüle
    burada 2 tane name=title kullanmışsınız ondan yapıyordur.
      <input type="text" class="form-control" id="sug_input" name="title" value="<?php echo remove_junk($product['name']); ?>">
                      <div id="result" class="list-group"></div>
                    </td>
                     <td id="s_must">
                      <input type="text" class="form-control" id="sug_input" name="title" value="<?php echo remove_junk($sale['must']); ?>">
    Merhaba, name="must" yaptığımda hata veriyor.

     <td id="s_must">
                      <input type="text" class="form-control" id="sug_input" name="must" value="<?php echo remove_junk($sale['must']); ?>">
                    </td>







    Database php
  • 04-03-2023, 11:52:48
    #4
    date='{$s_date}'must='{$s_must}

    araya virgül koymayı unutmuşsunuz.
  • 04-03-2023, 12:05:28
    #5
    ntka adlı üyeden alıntı: mesajı görüntüle
    date='{$s_date}'must='{$s_must}

    araya virgül koymayı unutmuşsunuz.
    ah bu virgüller yok mu ) teşekkürler