• 12-06-2014, 16:02:56
    #10
    DOS adlı üyeden alıntı: mesajı görüntüle
    Arkadaşlar PHP'de hesaplama işlemleriyle ilgili sorunum var yardımcı olabilirmisiniz rica etsem?

    <?php
    
    $q1_sayi1 = $_POST["q1_sayi1"];
    if($q1_sayi1==""){}else{
    
    $q3_sayi2 = $_POST["q3_sayi2"];
    if($q3_sayi2==""){}else{
    
    $q4_sayi3 = $_POST["q4_sayi3"];
    if($q4_sayi3==""){}else{
    
    $hesapla = ($q1_sayi1*$q3_sayi2/$q4_sayi3)/50;
    
    }
    }
    }
    ?>
    Bir değişkenimiz Var.. "$hesapla"
    Değişkenimizin çıkan sonucuna göre Sabit bir sayı olması gerekiyor mesela..

    30'dan Büyük 40'dan Küçükse ($hesapla 40 Olmalı )
    50'den Büyük 60'dan Küçükse ($hesapla 60 Olmalı )
    60'dan büyük 70'den Küçükse ($hesapla 70 Olmalı )

    Bir Arkadaşın Verdiği Örnek Kod ( Ama Çalışmadı. )

    if ($hesapla<40 and $hesapla>50) { $hesapla = 50; }
    NOT: Konu Güncellendi.
    $hesapla= "45";
    if (40 < $hesapla && $hesapla < 50) { $deger = 50; }else {$deger = 0;} 
    echo $deger;
  • 12-06-2014, 16:35:03
    #11
    if($_POST){
    $q1_sayi1=isset($_POST["q1_sayi1"]) && !empty($_POST["q1_sayi1"]) ? intval($_POST["q1_sayi1"]) : "0";
    $q3_sayi2=isset($_POST["q3_sayi2"]) && !empty($_POST["q3_sayi2"]) ? intval($_POST["q3_sayi2"]) : "0";
    $q4_sayi3=isset($_POST["q4_sayi3"]) && !empty($_POST["q4_sayi3"]) ? intval($_POST["q4_sayi3"]) : "0";
    $hesapla=ceil($q1_sayi1*$q3_sayi2/$q4_sayi3)/50;
    if($hesapla > 30 && $hesapla < 40):
    $hesapla="40";
    elseif($hesapla > 50 && $hesapla < 60):
    $hesapla="60";
    elseif($hesapla > 60 && $hesapla < 70):
    $hesapla="70";
    else:
    $hesapla="0";
    endif;
    echo "Cikti <strong> {$hesapla}</strong>";
    }