2016-03-25 10 views
1

. ama kaydetmeyi tıkladıktan sonra hiçbir şey çıkmaz. veritabanı ile uygun bir bağlantı var, veritabanındaki sütun adları da verdiğim ile aynı, yeniden kontrol ediliyor. yeni kullanıcı ve yardıma ihtiyacı var. hatamı düzeltmek i bulamadım lütfen:birden çok ekleme sorguları bu çalışma yapmaya çalışıyorum

<?php 
if (isset($_POST['submitted1'])==1) { 

    $areas12 = mysqli_real_escape_string($dbc, $_POST['areas12']); 
    $maxp12 = mysqli_real_escape_string($dbc, $_POST['maxp12']); 
    $minp12 = mysqli_real_escape_string($dbc, $_POST['minp12']); 
    $areae12 = mysqli_real_escape_string($dbc, $_POST['areae12']); 
    $volume12 = mysqli_real_escape_string($dbc, $_POST['volume12']); 

    $amount_change = $areas12-$areae12; 
    $percent_change = ($amount_change/$areas12)*100; 

    $q = "INSERT INTO ".$_SESSION['user_name']." (year, area_s, maxp, minp, area_e, volume,amount_change, percentage_change) VALUES ('2012-12-31', '$areas12', '$maxp12', '$minp12', '$areae12', '$volume12', '$amount_change', '$percent_change')" ; 
    $r = mysqli_query($dbc, $q); 
    if ($r) { 
     echo 'please fill up the data of year 2012-13'; 
    } 
    else { 
     echo 'please enter some data or error :'.mysqli_error($dbc); 
     echo '<p>'.$q.'</p>'; 
    } 

} 

if (isset($_POST['submitted2'])==1) { 

    $areas13 = mysqli_real_escape_string($dbc, $_POST['areas13']); 
    $maxp13 = mysqli_real_escape_string($dbc, $_POST['maxp13']); 
    $minp13 = mysqli_real_escape_string($dbc, $_POST['minp13']); 
    $areae13 = mysqli_real_escape_string($dbc, $_POST['areae13']); 
    $volume13 = mysqli_real_escape_string($dbc, $_POST['volume13']); 

    $amount_change = $areas13-$areae13; 
    $percent_change = ($amount_change/$areas13)*100; 

    $q = "INSERT INTO ".$_SESSION['user_name']." (year, area_s, maxp, minp, area_e, volume,amount_change, percentage_change) VALUES ('2013-12-31', '$areas13', '$maxp13', '$minp13', '$areae13', '$volume13', '$amount_change', '$percent_change')" ; 
    $r = mysqli_query($dbc, $q); 
    if ($r) { 
     echo 'please fill up the data of year 2013-14'; 
    } 
    else { 
     echo 'please enter some data or error :'.mysqli_error($dbc); 
     echo '<p>'.$q.'</p>'; 
    } 

} 

if (isset($_POST['submitted3'])==1) { 

    $areas14 = mysqli_real_escape_string($dbc, $_POST['areas14']); 
    $maxp14 = mysqli_real_escape_string($dbc, $_POST['maxp14']); 
    $minp14 = mysqli_real_escape_string($dbc, $_POST['minp14']); 
    $areae14 = mysqli_real_escape_string($dbc, $_POST['areae14']); 
    $volume14 = mysqli_real_escape_string($dbc, $_POST['volume14']); 

    $amount_change = $areas14-$areae14; 
    $percent_change = ($amount_change/$areas14)*100; 

    $q = "INSERT INTO ".$_SESSION['user_name']." (year, area_s, maxp, minp, area_e, volume,amount_change, percentage_change) VALUES ('2013-12-31', '$areas14', '$maxp14', '$minp14', '$areae14', '$volume14', '$amount_change', '$percent_change')" ; 
    $r = mysqli_query($dbc, $q); 
    if ($r) { 
     echo 'please fill up the data of year 2014-15'; 
    } 
    else { 
     echo 'please enter some data or error :'.mysqli_error($dbc); 
     echo '<p>'.$q.'</p>'; 
    } 
} 


if (isset($_POST['submitted4'])==1) { 

    $areas15 = mysqli_real_escape_string($dbc, $_POST['areas15']); 
    $maxp15 = mysqli_real_escape_string($dbc, $_POST['maxp15']); 
    $minp15 = mysqli_real_escape_string($dbc, $_POST['minp15']); 
    $areae15 = mysqli_real_escape_string($dbc, $_POST['areae15']); 
    $volume15 = mysqli_real_escape_string($dbc, $_POST['volume15']); 

    $amount_change = $areas15-$areae15; 
    $percent_change = ($amount_change/$areas15)*100; 

    $q = "INSERT INTO ".$_SESSION['user_name']." (year, area_s, maxp, minp, area_e, volume,amount_change, percentage_change) VALUES ('2013-12-31', '$areas15', '$maxp15', '$minp15', '$areae15', '$volume15', '$amount_change', '$percent_change')" ; 
    $r = mysqli_query($dbc, $q); 
    if ($r) { 
     echo 'please fill up the data of year 2015-16'; 
    } 
    else { 
     echo 'please enter some data or error :'.mysqli_error($dbc); 
     echo '<p>'.$q.'</p>'; 
    } 
} 


if (isset($_POST['submitted5'])==1) { 

    $areas16 = mysqli_real_escape_string($dbc, $_POST['areas16']); 
    $maxp16 = mysqli_real_escape_string($dbc, $_POST['maxp16']); 
    $minp16 = mysqli_real_escape_string($dbc, $_POST['minp16']); 
    $areae16 = mysqli_real_escape_string($dbc, $_POST['areae16']); 
    $volume16 = mysqli_real_escape_string($dbc, $_POST['volume16']); 

    $amount_change = $areas16-$areae16; 
    $percent_change = ($amount_change/$areas16)*100; 

    $q = "INSERT INTO ".$_SESSION['user_name']." (year, area_s, maxp, minp, area_e, volume,amount_change, percentage_change) VALUES ('2013-12-31', '$areas16', '$maxp16', '$minp16', '$areae16', '$volume16', '$amount_change', '$percent_change')" ; 
    $r = mysqli_query($dbc, $q); 
    if ($r) { 
     header('location:stock.php'); 
    } 
    else { 
     echo 'please enter some data or error :'.mysqli_error($dbc); 
     echo '<p>'.$q.'</p>'; 
    } 
} 
?> 

<!DOCTYPE html> 
<html> 
<head> 

<meta name="viewport" content="width=device-width, initial-scale=1"> 

<?php include('../config/css.php'); ?> 
<?php include('../config/js.php'); ?>  
<title>stock details</title> 
</head> 
<body> 


    <?php include('../template/navigation.php'); ?> 

    <h1><center><strong>Farm Stock Details</strong></center></h1> 

    <div class="col-md-6 col-md-offset-3"> 
     <table class="table" align="center"> 
     <tr> 
      <thead> 
       <td>year</td> 
       <td>Area at the starting year</td> 
       <td>Maximum profit per hectare</td> 
       <td>Minimum profit per hectare</td> 
       <td>Area at the ending year</td> 
       <td>Area in hectare</td> 
       <td></td> 
      </thead> 
     </tr> 

     <tr> 
      <td>2011-2012</td> 
      <td><input type="number" id="areas12" name="areas12"></td> 
      <td><input type="number" id="maxp12" name="maxp12"></td> 
      <td><input type="number" id="minp12" name="minp12"></td> 
      <td><input type="number" id="areae12" name="areae12"></td> 
      <td><input type="number" id="volume12" name="volume12"></td> 
      <td> 
       <button type="submit" class="btn btn-primary btn btn-block">Save</button> 
       <input type="hidden" name="submitted1" value="1"> 
      </td> 
     </tr> 

     <tr> 
      <td>2012-2013</td> 
      <td><input type="number" id="areas13" name="areas13"></td> 
      <td><input type="number" id="maxp13" name="maxp13"></td> 
      <td><input type="number" id="minp13" name="minp13"></td> 
      <td><input type="number" id="areae13" name="areae13"></td> 
      <td><input type="number" id="volume13" name="volume13"></td> 
      <td><button type="submit" class="btn btn-primary btn btn-block">Save</button> 
       <input type="hidden" name="submitted2" value="1"> 
       </div> 
      </td> 
     </tr> 

     <tr> 
      <td>2013-2014</td> 
      <td><input type="number" id="areas14" name="areas14"></td> 
      <td><input type="number" id="maxp14" name="maxp14"></td> 
      <td><input type="number" id="minp14" name="minp14"></td> 
      <td><input type="number" id="areae14" name="areae14"></td> 
      <td><input type="number" id="volume14" name="volume14"></td> 
      <td><button type="submit" class="btn btn-primary btn btn-block">Save</button> 
       <input type="hidden" name="submitted3" value="1"> 
       </div> 
      </td> 
     </tr> 

     <tr> 
      <td>2014-2015</td> 
      <td><input type="number" id="areas15" name="areas15"></td> 
      <td><input type="number" id="maxp15" name="maxp15"></td> 
      <td><input type="number" id="minp15" name="minp15"></td> 
      <td><input type="number" id="areae15" name="areae15"></td> 
      <td><input type="number" id="volume15" name="volume15"></td> 
      <td><button type="submit" class="btn btn-primary btn btn-block">Save</button> 
       <input type="hidden" name="submitted4" value="1"> 
       </div> 
      </td> 
     </tr> 

     <tr> 
      <td>2015-2016</td> 
      <td><input type="number" id="areas16" name="areas16"></td> 
      <td><input type="number" id="maxp16" name="maxp16"></td> 
      <td><input type="number" id="minp16" name="minp16"></td> 
      <td><input type="number" id="areae16" name="areae16"></td> 
      <td><input type="number" id="volume16" name="volume16"></td> 
      <td><button type="submit" class="btn btn-primary btn btn-block">Save</button> 
      <input type="hidden" name="submitted5" value="1"> 
      </div></td> 
     </tr> 
     </table> 
    </div> 
</body> 
</html> 
+2

aksi anyting gündeme getirmeyeceği Gönder düğmesini html'nizin bir "Form" öğe ekleyin. – Indrajit

+0

Düzenleme için teşekkürler. Bunun için yeniyim. – Prathameshb7

cevap

0

Bear akılda, bir ebeveyn formu veya bir şey yapmayacağım bir js dinleyici olmadan girişini gönderin. Yani en basit yolu, örneğin, aksiyon sayfanızın adı olarak sahip bir <form> yapmak olacaktır:

<form action="<?echo $PAGE_NAME?>" method="POST" > 
    <table class="table" align="center"> 
    <tr> 
     <thead> 
      <td>year</td> 
      <td>Area at the starting year</td> 
      <td>Maximum profit per hectare</td> 
      <td>Minimum profit per hectare</td> 
      <td>Area at the ending year</td> 
      <td>Area in hectare</td> 
      <td></td> 
     </thead> 
    </tr> 

    <tr> 
     <td>2011-2012</td> 
     <td><input type="number" id="areas12" name="areas12"></td> 
     <td><input type="number" id="maxp12" name="maxp12"></td> 
     <td><input type="number" id="minp12" name="minp12"></td> 
     <td><input type="number" id="areae12" name="areae12"></td> 
     <td><input type="number" id="volume12" name="volume12"></td> 
     <td> 
      <button type="submit" class="btn btn-primary btn btn-block">Save</button> 
      <input type="hidden" name="submitted1" value="1"> 
     </td> 
    </tr> 

    <tr> 
     <td>2012-2013</td> 
     <td><input type="number" id="areas13" name="areas13"></td> 
     <td><input type="number" id="maxp13" name="maxp13"></td> 
     <td><input type="number" id="minp13" name="minp13"></td> 
     <td><input type="number" id="areae13" name="areae13"></td> 
     <td><input type="number" id="volume13" name="volume13"></td> 
     <td><button type="submit" class="btn btn-primary btn btn-block">Save</button> 
      <input type="hidden" name="submitted2" value="1"> 
      </div> 
     </td> 
    </tr> 

    <tr> 
     <td>2013-2014</td> 
     <td><input type="number" id="areas14" name="areas14"></td> 
     <td><input type="number" id="maxp14" name="maxp14"></td> 
     <td><input type="number" id="minp14" name="minp14"></td> 
     <td><input type="number" id="areae14" name="areae14"></td> 
     <td><input type="number" id="volume14" name="volume14"></td> 
     <td><button type="submit" class="btn btn-primary btn btn-block">Save</button> 
      <input type="hidden" name="submitted3" value="1"> 
      </div> 
     </td> 
    </tr> 

    <tr> 
     <td>2014-2015</td> 
     <td><input type="number" id="areas15" name="areas15"></td> 
     <td><input type="number" id="maxp15" name="maxp15"></td> 
     <td><input type="number" id="minp15" name="minp15"></td> 
     <td><input type="number" id="areae15" name="areae15"></td> 
     <td><input type="number" id="volume15" name="volume15"></td> 
     <td><button type="submit" class="btn btn-primary btn btn-block">Save</button> 
      <input type="hidden" name="submitted4" value="1"> 
      </div> 
     </td> 
    </tr> 

    <tr> 
     <td>2015-2016</td> 
     <td><input type="number" id="areas16" name="areas16"></td> 
     <td><input type="number" id="maxp16" name="maxp16"></td> 
     <td><input type="number" id="minp16" name="minp16"></td> 
     <td><input type="number" id="areae16" name="areae16"></td> 
     <td><input type="number" id="volume16" name="volume16"></td> 
     <td><button type="submit" class="btn btn-primary btn btn-block">Save</button> 
     <input type="hidden" name="submitted5" value="1"> 
     </div></td> 
    </tr> 
    </table> 
</form>