Jump to content

ainbila

Members
  • Posts

    25
  • Joined

  • Last visited

Posts posted by ainbila

  1. i try this code to rename file when upload , the file name is rename in the folder or physical file .But in the database , it display 'array' not the name of file .How to save file name in the database ?

     

    $targetDirg= "folder/pda-semakan/gambar/";
     if($_FILES['gambar']['size'] == 0 && $_FILES['gambar']['name'] == ""){
       $fileNameg = $gambar;
     }else{
    $fileNameg =explode(".",$_FILES['gambar']['name']);
    $newfilename= $stIC.'.'.end($fileNameg);
    
     
     $moveg =move_uploaded_file($_FILES["gambar"]["tmp_name"], $targetDirg.$newfilename);
     }

     

  2. On 7/31/2021 at 11:27 PM, Strider64 said:
        if ($_FILES['image']['size'] >= 44040192) {
            $errors[] = 'File size must be less than or equal to 42 MB';
        }

    Simply check the file size and throw and throw an error if it is too big. I would also on the HTML page state the maximum file size allowed to upload. You could also try to compress the file, but that gets more involved.

    Thank you . Do you know if there have code for reupload file in php ?

  3. how to put code for check file size before upload  in the if issertfile .the file is in format pdf or docs 

     $targetDirg= "folder/pda-semakan/gambar/";
     if(isset($_FILES['gambar'])){
         $fileNameg = $_FILES['gambar']['name'];
     $targetFilePathg = $targetDirg . $fileNameg;
     //$main_tmp1 = $_FILES['surat']['tmp_name'];
     $moveg =move_uploaded_file($_FILES["gambar"]["tmp_name"], $targetFilePathg);
     }  
             
     

     


  4. is there any way to put function compress pdf file size in this code . Because when user upload big file size , it will get error . So , i'm looking code that can auto resize the pdf file in php

    $targetDir7= "folder/pda-semakan/bm/";
    if(isset($_FILES['bmjulai'])){
         $fileName7= $_FILES['bmjulai']['name'];
     $targetFilePath7 = $targetDir7 . $fileName7;
    $move8=move_uploaded_file($_FILES["bmjulai"]["tmp_name"], $targetFilePath7);
    }

     

  5. files that upload during insert/submit form was gone , only files upload during the update remain , is the way query for update multiple files is wrong ?

    
    $targetDir1= "folder/pda-semakan/ic/";
    if(isset($_FILES['ic'])){
         $fileName1 = $_FILES['ic']['name'];
     $targetFilePath1 = $targetDir1 . $fileName1;
     //$main_tmp2 = $_FILES['ic']['tmp_name'];
    $move2 =move_uploaded_file($_FILES["ic"]["tmp_name"], $targetFilePath1);
    }
    
    $targetDir2= "folder/pda-semakan/sijil_lahir/";
    if(isset($_FILES['sijilkelahiran'])){
         $fileName2 = $_FILES['sijilkelahiran']['name'];
     $targetFilePath2 = $targetDir2 . $fileName2;
    $move3 =move_uploaded_file($_FILES["sijilkelahiran"]["tmp_name"], $targetFilePath2);
    }
    
    $targetDir3= "folder/pda-semakan/sijil_spm/";
    if(isset($_FILES['sijilspm'])){
         $fileName3 = $_FILES['sijilspm']['name'];
     $targetFilePath3 = $targetDir3 . $fileName3;
    $move4 =move_uploaded_file($_FILES["sijilspm"]["tmp_name"], $targetFilePath3);
    }
    
    
    
    $query1=("UPDATE semakan_dokumen set student_id='$noMatrik', email= '$stdEmail', surat_tawaran='$fileName', ic='$fileName1',sijil_lahir='$fileName2',sijil_spm= '$fileName3' where email= '$stdEmail'");
    

     

  6. i have error where my code should update existing data where id exist, it get updated ..but the others data is disappeared .only the data updated is remained 

    $sql1 ="select*from semakan_dokumen where email='$stdEmail'";
    $sqlsearch1 = mysqli_query($dbconfig,$sql1);
    $resultcount1 = mysqli_num_rows($sqlsearch1);
    
    if($resultcount1 > 0){
    $query1=("UPDATE  semakan_dokumen set student_id='$noMatrik', email= '$stdEmail', surat_tawaran='$fileName', ic='$fileName1',sijil_lahir='$fileName2',sijil_spm= '$fileName3',sijil_sekolah= '$fileName4', sijil_dip= '$fileName5',sej_julai='$fileName6',bm_julai='$fileName7',muet='$fileName8', mid1='$fileName9',yuran= '$fileName10',umpa_bend1= '$fileName11',umpa_bend2='$fileName12',bpkp='$fileName13', penaja='$fileName14',kesihatan= '$fileName15', jhepa='$fileName16' where email= '$stdEmail' ");
    
    }else{
    
    
    //filezip
    $query1 = "INSERT INTO semakan_dokumen (email,surat_tawaran,ic,sijil_lahir,sijil_spm,sijil_sekolah,sijil_dip,sej_julai,bm_julai,muet,mid1,yuran,umpa_bend1,umpa_bend2,bpkp,penaja,kesihatan,jhepa) VALUES ('$stdEmail','$fileName','$fileName1','$fileName2','$fileName3','$fileName4','$fileName5','$fileName6','$fileName7','$fileName8','$fileName9','$fileName10','$fileName11','$fileName12','$fileName13','$fileName14','$fileName15','$fileName16')";
    }

     

  7. hi , i want to disable or hide the submit button after user submit and just display the update button .My problem is this form in form of tab by tab .so i dont know how to disable the button

    report.thumb.PNG.5c845d21b01c94decb58219e49ba91ae.PNG

    button javascript

     $('#btn_confirmation1').click(function(){
    
              $('#btn_confirmation1').attr("disabled", true);
              $(document).css('cursor', 'prgress');
    
    
              $("#application-form1").submit();
    
               return true;
            
          });

    form (all in one page)

     <form id="application-form1"  action="save_form_semakan.php" method="POST" enctype="multipart/form-data">
    							<!--tab nav tabs-->
    							<?php include 'nav_tabs1.php';?>
    
    							<div class="tab-content" style="margin-top:16px;">
    								<!--tab application guideline-->
    								
    								<?php include ("tab_semak1.php")?>

     

  8. hi , i have an error in my php . It will display successful only if all file being upload , if there have one file not upload . it go to blankpage not tell any error or success.I have file that being upload to different path folder

     

     $fileName14 = basename($_FILES["penaja"]["name"]);
            $targetFilePath14=$targetDir14. $fileName14;
            $fileType14 = pathinfo($targetFilePath14,PATHINFO_EXTENSION);
            $allowTypes14=  array('pdf','PDF','docx','DOCX');
              //kesihatan
             $targetDir15 ="folder/pda-semakan/kesihatan/";
            $fileName15 = basename($_FILES["umpapkp"]["name"]);
            $targetFilePath15=$targetDir15. $fileName15;
            $fileType15 = pathinfo($targetFilePath15,PATHINFO_EXTENSION);
            $allowTypes15=  array('pdf','PDF','docx','DOCX');
    
            //jhepa
             $targetDir16 ="folder/pda-semakan/jhepa/";
            $fileName16 = basename($_FILES["umpajhepa"]["name"]);
            $targetFilePath16=$targetDir16. $fileName16;
            $fileType16 = pathinfo($targetFilePath16,PATHINFO_EXTENSION);
            $allowTypes16=  array('pdf','PDF','docx','DOCX');
    
    
    
    
            
         
            if(in_array($fileTypeg, $allowTypesg)){
           if(in_array($fileType, $allowTypes)){
             if(in_array($fileType1, $allowTypes1)){
               if(in_array($fileType2, $allowTypes2)){
                 if(in_array($fileType3, $allowTypes3)){
                  if(in_array($fileType4, $allowTypes4)){
                    if(in_array($fileType5, $allowTypes5)){
                     if(in_array($fileType6, $allowTypes6)){
                            if(in_array($fileType7, $allowTypes7)){
    
    
    
                // Upload file to server
                    if(move_uploaded_file($_FILES["gambar"]["tmp_name"], $targetFilePathg)){
                    if(move_uploaded_file($_FILES["surat"]["tmp_name"], $targetFilePath)){
                          if(move_uploaded_file($_FILES["ic"]["tmp_name"], $targetFilePath1)){
                             if(move_uploaded_file($_FILES["sijilkelahiran"]["tmp_name"], $targetFilePath2)){ if(move_uploaded_file($_FILES["sijilspm"]["tmp_name"], $targetFilePath3)){
                             if(move_uploaded_file($_FILES["sijilberhenti"]["tmp_name"], $targetFilePath4)){  
                              if(move_uploaded_file($_FILES["sijilmatrik"]["tmp_name"], $targetFilePath5)){   
                               if(move_uploaded_file($_FILES["sejulai"]["tmp_name"], $targetFilePath6)){
                                       if(move_uploaded_file($_FILES["bmjulai"]["tmp_name"], $targetFilePath7)){                       
                                            
                                            

     

  9. the symbol is gone now . but how to remove the space ?

    SELECT IFNULL(race_id,''), IFNULL(race_code,''), IFNULL(ptmk_race_code,''),IFNULL(race_name,''),IFNULL(keyin_by,''),IFNULL(keyin_date,'')
    INTO OUTFILE 'pp.txt'
    FIELDS TERMINATED by ''
    from race

    the data should follow the row value like in the db structure

    race.PNG.edbabccb4eb519401fad74837a4f9744.PNG

    like :

    race_id  (1-11)

    race_code(12-31)

     

    now the output include many spaces : 

    pp.thumb.PNG.31b029abab2ade361c16ad3ae8e69c62.PNG

  10. hi everyone ,i export data from table in phpmyadmin to txtfile 

    SELECT * FROM employees  INTO OUTFILE '/tmp/test.txt' FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY "" LINES TERMINATED BY ' ';

    there is some problem

    1) i dont want the symbol 

    2) i want to keep column value when user not enter any value follow database structure 

     

    sav.PNG.443fdc5858180475c6af0a237fb29e4b.PNG 

    between chia jun and date there is space because there have some column .

    for example like in the imagetest.thumb.PNG.e791f6132c5efc694eeeb5ed264639f9.PNG

     

     

     

     

  11. i'm sorry

    if (($sub == 'SNT') || ($sub == 'LKJ') || ($sub == 'GRA') || ($sub == 'GKT') || ($sub == 'TEK') || ($sub == 'PJA') || ($sub == 'BIO') || ($sub == 'PJE') || ($sub == 'PJM') || ($sub == 'PSS') || ($sub == 'PEE') || ($sub == 'MUL') || ($sub == 'PDT') || ($sub == 'RKB') || ($sub == 'RT') || ($sub == 'SS')){
                           if ($res == 0) {
                            $merit = 18;
                          }
                          if ($res == 1) {
                            $merit = 16;
                          }
                          if ($res == 2) {
                            $merit = 14;
                          }
                          if ($res == 3) {
                            $merit = 12;
                          }
                          if ($res == 4) {
                            $merit = 10;
                          }
                          if ($res == 5) {
                            $merit = 8;
                          }
                          if ($res == 6) {
                            $merit = 6;
                          }
                          if ($res == 7) {
                            $merit = 4;
                          }
                          if ($res == 8) {
                            $merit = 2;
                          }
                          if ($res == 9) {
                            $merit = 0;
                          }
    
                          $main_add_merit = $merit;
     $k[$i] = $merit;
    rsort($k);
    $arrlength = count($k);
    
    for($x = 0; $x < 1; $x++) {
     
    
     $main_add_merit=$k[$x];
    
     $main_add_merit;
      
                        
                          
                        }
    }
                
                    
      
    
                       if ((($sub == 'BM')  || ($sub == 'BI') ||  ($sub == 'SEJ') || ($sub == 'PQS') || ($sub == 'PSI')|| ($sub == 'BAT')|| ($sub == 'PI'))){
                          if ($res == 0) {
                            $merit = 18;
                          }
                          if ($res == 1) {
                            $merit = 16;
                          }
                          if ($res == 2) {
                            $merit = 14;
                          }
                          if ($res == 3) {
                            $merit = 12;
                          }
                          if ($res == 4) {
                            $merit = 10;
                          }
                          if ($res == 5) {
                            $merit = 8;
                          }
                          if ($res == 6) {
                            $merit = 6;
                          }
                          if ($res == 7) {
                            $merit = 4;
                          }
                          if ($res == 8) {
                            $merit = 2;
                          }
                          if ($res == 9) {
                            $merit = 0;
                          }
    
    
                      
    
                          $main_add_merit1 = $merit;
                        
    
                           $s[$i] = $main_add_merit1;
                           //echo '<br>';
                           rsort($s);
    
    
    echo '<pre>' . print_r( $s, true) . '</pre>';
    $sum = array_sum(array_slice($s, 0, 3));
    
     echo $sum;
    
    
    
    
                        
     
    
    }
    
    
     
     
    
    
     
    
    
    
    
     
     
    
    }
    
    
    
    }
    
      

    there is error in my if else that got wrong subject. array_slice() also can be used for sum . i want to find 3 subject highest value ,the subject must be others than the first if else . 

  12.  rsort($y);
    
    echo '<pre>' . print_r( $y , true) . '</pre>';
    
    
    output for 4 student:
    
    Array
    (
        [0] => 16
        [1] => 14
        [2] => 12
        [3] => 10
        [4] => 8
        [5] => 6
    )
    Array
    (
        [0] => 16
        [1] => 12
        [2] => 10
        [3] => 6
    )
    Array
    (
        [0] => 16
        [1] => 14
        [2] => 12
        [3] => 10
        [4] => 6
    )
    Array
    (
        [0] => 16
        [1] => 14
        [2] => 12
        [3] => 10
        [4] => 8
        [5] => 6
    )

    this is the output of array after the sorting .and i want to sum 3 highest value .like 16+14+12

  13. i've tried the array_slice .the first sum is right ,but after that it got wrong total and being looping decreasing .right now 

    the array is giving right value .

    for example :

    1210 161014

    this is array for 2 student . so first student will get 12+10 ,and second will get 16+10+14 .this student get value based on merit grade of their 3 maximum subject from else if

  14. is it possible to calculate sum of the element in the array_pop . i have to get sum of 3 maximum subject with grade from student .

     

     else if (($sub == 'BI') || ($sub == 'TSI') || ($sub == 'PAP') || ($sub == 'PAK'))  { 
    
                          
                          
    if ($res == 0) {
                            $merit = 18;
                          }
                          if ($res == 1) {
                            $merit = 16;
                          }
                          if ($res == 2) {
                            $merit = 14;
                          }
                          if ($res == 3) {
                            $merit = 12;
                          }
                          if ($res == 4) {
                            $merit = 10;
                          }
                          if ($res == 5) {
                            $merit = 8;
                          }
                          if ($res == 6) {
                            $merit = 6;
                          }
                          if ($res == 7) {
                            $merit = 4;
                          }
                          if ($res == 8) {
                            $merit = 2;
                          }
                          if ($res == 9) {
                            $merit = 0;
                          }
    
    
                     
    
                          $main_add_merit1 = $merit;
                        
                              $main_add_merit1;
    
                              $y[$i] = $main_add_merit1;
                           //echo '<br>';
                           rsort($y);
    
    
      $first = array_pop($y);
      
    
                        }
     
    
    
    
    
     

     

  15. <!DOCTYPE html>
    <html>
    <head>
      <!-- Basic Page Info -->
      <meta http-equiv="refresh" content="900;url=index.php" />
      <meta charset="utf-8">
      <title>Student Admission</title>
    
      <!-- Site favicon -->
      <link rel="apple-touch-icon" sizes="180x180" href="vendors/images/apple-touch-icon.png">
      <link rel="icon" type="image/png" sizes="32x32" href="vendors/images/favicon-32x32.png">
      <link rel="icon" type="image/png" sizes="16x16" href="vendors/images/favicon-16x16.png">
    
    
      <!-- Mobile Specific Metas -->
      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
      <!-- Google Font -->
      <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
      <!-- CSS -->
      <link rel="stylesheet" type="text/css" href="vendors/styles/core.css">
      <link rel="stylesheet" type="text/css" href="vendors/styles/icon-font.min.css">
      <link rel="stylesheet" type="text/css" href="src/plugins/jquery-steps/jquery.steps.css">
      <link rel="stylesheet" type="text/css" href="vendors/styles/style.css">
      <link rel="stylesheet" href="src/styles/yearpicker.css">
      <link rel="stylesheet" type="text/css" href="src/plugins/datatables/css/dataTables.bootstrap4.min.css">
      <link rel="stylesheet" type="text/css" href="src/plugins/datatables/css/responsive.bootstrap4.min.css">
    
      <!-- Global site tag (gtag.js) - Google Analytics -->
      <script async src="https://www.googletagmanager.com/gtag/js?id=UA-119386393-1"></script>
      <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());
    
        gtag('config', 'UA-119386393-1');
      </script>
      <style>
        .float{
          position:fixed;
    
          bottom:70px;
          right:70px;
    
    
          text-align:center;
          box-shadow: 2px 2px 3px #999;
        }
        .ui-datepicker-calendar {
          display: none;
        }
      </style>
    </head>
    <?php
    session_start();
    include_once 'talum.php';
    error_reporting(E_ALL ^ E_NOTICE);
    
    if(isset($_SESSION['login_username']))
    {
      $login_session=$_SESSION['login_username'];
    
      $sql_query="SELECT * FROM master_admission_login WHERE login_username = '$login_session' ";
      $res=mysqli_query($dbconfig2,$sql_query);
      $userRow=mysqli_fetch_array($res,MYSQLI_ASSOC);
      $userUsername = $userRow['login_username'];
      
      $userName = $userRow['login_name'];
      $userRole = $userRow['login_role'];
    
      date_default_timezone_set("asia/kuala_lumpur");
      $thisyear = date('Y');
      $nextyear = date('Y')+1;
    
      $appAgentId = $_REQUEST['id'];
    
      if($userRole=='agent'){
        $sql="SELECT * FROM application_agent_info WHERE id = '$appAgentId'";
        $result=mysqli_query($dbconfig,$sql);
        $row=mysqli_fetch_array($result,MYSQLI_ASSOC);
        $studentEmail = $row['std_email'];
        $studentIC = $row['std_ic'];
      }else if($userRole=='student'){
        $studentEmail = $userUsername;
      }
    
    
    
      
    
      ?>
    
    <body>
        
        <!--header-->
        <?php include("header.php"); ?> 
    
        <!--right_side-->
        <?php include("right_side.php"); ?>
    
        <!--left_side-->
        <?php include("left_side.php"); ?>
    
        <div class="mobile-menu-overlay"></div>
        
        
        <div class="main-container">
          <div class="pd-ltr-20 xs-pd-20-10">
            <form action="stdUpdate.php" method="POST" enctype="multipart/form-data">
              <div class="min-height-200px">
                <div class="page-header">
            <div class="row">
              <div class="col-md-6 col-sm-12">
                <div class="title">
                  <h4>DataTable</h4>
                </div>
                <nav aria-label="breadcrumb" role="navigation">
                  <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                    <li class="breadcrumb-item active" aria-current="page">List Student</li>
                  </ol>
                </nav>
              </div>
              
            </div>
          </div>
          <!-- Export Datatable start -->
            <div class="card-box mb-30">
              <div class="pd-20">
                <h4 class="text-blue h4">List of Application</h4>
              </div>
              <div class="pb-20">
                <table class="table hover multiple-select-row data-table-export nowrap">
                  <thead>
                    <tr>
                      <th class="table-plus datatable-nosort">No</th>
                      <th>Name</th>
                      <th>IC No</th>
                      <th>aliran</th>
                      <!--th>First Choice</th>
                      <th>Date Application</th-->
                      <th>Program</th>
                      <th>Markah MP Utama Aliran  </th>
                      <th>Markah MP Terbaik</th>
                       <th>Markah Akademik</th>
                    </tr>
                  </thead>
                  <tbody>
    
    
    
      
    <?php
    
    
    
    
     
    
            $sql3="SELECT DISTINCT * FROM application_pda inner join application_program on application_pda.au_ic=application_program.st_ic where application_program.first_choice='DIP'  ";
    
            $app=mysqli_query($dbconfig,$sql3);
      
            
    
            while($row=mysqli_fetch_array($app,MYSQLI_ASSOC)){
            
    
    
              $id = $row['au_id'];
              $email = $row['au_email'];
              $ic= $row['au_ic'];
              $name = $row['au_name'];
    
    
              $sql="SELECT * FROM application_pda INNER JOIN qualification_result where qualification_result.st_ic = '$ic' AND application_pda.au_ic = qualification_result.st_ic  and qualification_result.new_entry_quali='2' ";
    
              $sql2 = "SELECT * FROM application_program  WHERE st_ic = '$ic'";
              $program_Result=mysqli_query($dbconfig,$sql2);
              $row2=mysqli_fetch_array($program_Result,MYSQLI_ASSOC);
    
    
    
    
              $first = $row2["first_choice"];
              $second = $row2["second_choice"];
              $third = $row2["third_choice"];
              $firstList = $row2['firstList'];
              $offer = 0;
    
              $result=mysqli_query($dbconfig,$sql);
              $row1=mysqli_fetch_array($result,MYSQLI_ASSOC);
              $subject = $row1['qr_subject'];
              $aliran = $row1['st_aliran'];
              //$grade = $row1['qr_result'];
                        $grade = $row1['qr_spm_result'];
    
    
    
              $subjects = (explode(",",$subject));
    
              $grades = (explode(",",$grade));
              //$grades1 = (explode(",",$grade1));
    
              $BM = 8;
              $BI = 8;
              $MAT = 8;
              $SN = 8;
              $SEJ = 8;
              $KIM = 8;
              $BIO = 8;
              $FIZ = 8;
              $SNT = 8;
              $SN = 8;
              $SPT = 8;
              $PJM = 8;
              $PJE = 8;
              $PJA = 8;
              $TKJ = 8;
              $TEK = 8;
              $LKJ = 8;
              $FOP = 8;
              $PDT = 8;
              $AKP = 8;
    
    
    
              $i = 0;
    
              
                  
    
              if ($grade != NULL){
    
              foreach ($subjects as $subject) {
               
                if($subject == 'BM'){
                  $BM = $grades[$i];
                        //echo 'BM = '.$grades[$i];
                }elseif($subject == 'BI'){
                  $BI = $grades[$i];
                        //echo 'BI = '.$grades[$i];
                }elseif($subject == 'MAT'){
                  $MAT = $grades[$i];
                        //echo 'MAT = '.$grades[$i];
                }elseif($subject == 'SN'){
                  $SN = $grades[$i];
                        //echo 'SN = '.$grades[$i];
                }elseif($subject == 'SEJ'){
                  $SEJ = $grades[$i];
                        //echo 'SEJ = '.$grades[$i];
                }elseif($subject == 'KIM'){
                  $KIM = $grades[$i];
                        //echo 'KIM = '.$grades[$i];
                }elseif($subject == 'BIO'){
                  $BIO = $grades[$i];
                        //echo 'BIO = '.$grades[$i];
                }elseif($subject == 'FIZ'){
                  $FIZ = $grades[$i];
                }elseif($subject == 'SNT'){
                  $SNT = $grades[$i];
                        //echo 'SNT = '.$grades[$i];
                }elseif($subject == 'SPT'){
                  $SPT = $grades[$i];
                        //echo 'SPT = '.$grades[$i];
                }elseif($subject == 'PJM'){
                  $PJM = $grades[$i];
                        //echo 'PJM = '.$grades[$i];
                }elseif($subject == 'PJE'){
                  $PJE = $grades[$i];
                        //echo 'PJE = '.$grades[$i];
                }elseif($subject == 'PJA'){
                  $PJA = $grades[$i];
                        //echo 'PJA = '.$grades[$i];
                }elseif($subject == 'TKJ'){
                  $TKJ = $grades[$i];
                        //echo 'TKJ = '.$grades[$i];
                }elseif($subject == 'TEK'){
                  $TEK = $grades[$i];
                        //echo 'TEK = '.$grades[$i];
                }elseif($subject == 'LKJ'){
                  $LKJ = $grades[$i];
                        //echo 'LKJ = '.$grades[$i];
                }elseif($subject == 'FOP'){
                  $FOP = $grades[$i];
                        //echo 'FOP = '.$grades[$i];
                }elseif($subject == 'PDT'){
                  $PDT = $grades[$i];
                        //echo 'PDT = '.$grades[$i];
                }elseif($subject == 'AKP'){
                  $AKP = $grades[$i];
                        //echo 'AKP = '.$grades[$i];
                }else{
                  
                }
    
    
                $i++;
              }
            }else {
    '';}
    
    
                     
                        
                  
                        
                        $countSub = count($subjects);
                        
                        //$results = (explode(",",$grades));
                         //to count no if result
                        $countRes = count($grades)-1;
                       
                        
                        $total_merit_mat= 0;
                        $total_merit_addmath = 0;
                        $total_merit_fiz= 0;
                        $total_merit_kim= 0;
                        $merit = 0;
                        $main_merit = 0;
                        $main_merit1 =0 ;
                        $main_add_merit = 0;
                        $total_merit = 0;
                        $total_all_merit = 0;
                       
                         //$meritAdd = 0;
                       
                        if(count($subjects) == count($grades)){
    
                        foreach(array_combine($subjects, $grades) as $sub => $res){
    
    
                        
                      if($aliran=='S'){
                         $sql4="SELECT * FROM `qualification_result` where st_aliran='S'";
                     $result4=mysqli_query($dbconfig,$sql4);
                      $row4=mysqli_fetch_array($result4,MYSQLI_ASSOC) ;
                        //$stEmail = $row4['st_email'];
                        //$stIC = $row3['st_ic'];
                        //$aliran1 = $row4['S'];
                       
    
                    
                        if (($sub == 'MAT') || ($sub == 'M-T') || ($sub == 'FIZ') || ($sub == 'KIM'))  {
                          if ($res == 0) {
                            $merit = 18;
                          }
                          if ($res == 1) {
                            $merit = 16;
                          }
                          if ($res == 2) {
                            $merit = 14;
                          }
                          if ($res == 3) {
                            $merit = 12;
                          }
                          if ($res == 4) {
                            $merit = 10;
                          }
                          if ($res == 5) {
                            $merit = 8;
                          }
                          if ($res == 6) {
                            $merit = 6;
                          }
                          if ($res == 7) {
                            $merit = 4;
                          }
                          if ($res == 8) {
                            $merit = 2;
                          }
                          if ($res == 9) {
                            $merit = 0;
                          }
                          
                          $main_merit += $merit;
                          
                        }
    
       //to select high mark for 5th subject
                        
                        else if (($sub == 'SNT') || ($sub == 'LKJ') || ($sub == 'GRA') || ($sub == 'GKT') || ($sub == 'TEK') || ($sub == 'PJA') || ($sub == 'BIO') || ($sub == 'PJE') || ($sub == 'PJM') || ($sub == 'PSS') || ($sub == 'PEE') || ($sub == 'MUL') || ($sub == 'PDT') || ($sub == 'RKB') || ($sub == 'RT') || ($sub == 'SS')){
                           if ($res == 0) {
                            $merit = 18;
                          }
                          if ($res == 1) {
                            $merit = 16;
                          }
                          if ($res == 2) {
                            $merit = 14;
                          }
                          if ($res == 3) {
                            $merit = 12;
                          }
                          if ($res == 4) {
                            $merit = 10;
                          }
                          if ($res == 5) {
                            $merit = 8;
                          }
                          if ($res == 6) {
                            $merit = 6;
                          }
                          if ($res == 7) {
                            $merit = 4;
                          }
                          if ($res == 8) {
                            $merit = 2;
                          }
                          if ($res == 9) {
                            $merit = 0;
                          }
    
                          $main_add_merit = $merit;
     $k[$i] = $merit;
    rsort($k);
    $arrlength = count($k);
    
    for($x = 0; $x < 1; $x++) {
     
     if ($x==3) break;
     $main_add_merit=$k[$x];
    
     $main_add_merit;
      
                        
                          
                        }
    }
                
                    
      
    
                       if ((($sub == 'BM')  || ($sub == 'BI') ||  ($sub == 'SEJ') || ($sub == 'PQS') || ($sub == 'PSI')|| ($sub == 'BAT')|| ($sub == 'PI'))){
                          if ($res == 0) {
                            $merit = 18;
                          }
                          if ($res == 1) {
                            $merit = 16;
                          }
                          if ($res == 2) {
                            $merit = 14;
                          }
                          if ($res == 3) {
                            $merit = 12;
                          }
                          if ($res == 4) {
                            $merit = 10;
                          }
                          if ($res == 5) {
                            $merit = 8;
                          }
                          if ($res == 6) {
                            $merit = 6;
                          }
                          if ($res == 7) {
                            $merit = 4;
                          }
                          if ($res == 8) {
                            $merit = 2;
                          }
                          if ($res == 9) {
                            $merit = 0;
                          }
    
    
                        $sum=0;
    
                          $main_add_merit1 = $merit;
                        
    
                           $s[$i] = $main_add_merit1;
                           //echo '<br>';
                           rsort($s);
    $arrlength = count($s);
    
    for($x = 0; $x < 3; $x++) {
     
     $sum += $s[$x];
    
       
    
    
                        } 
     
    
    }
    
    
     
     
    
    } 
                      else if($aliran=='A'){
                         $sql4="SELECT * FROM `qualification_result` where st_aliran='S'";
                     $result4=mysqli_query($dbconfig,$sql4);
                      $row4=mysqli_fetch_array($result4,MYSQLI_ASSOC) ;
                        //$stEmail = $row4['st_email'];
                        //$stIC = $row3['st_ic'];
                        //$aliran1 = $row4['S'];
                       
    
                    
                        if (($sub == 'BM') || ($sub == 'MAT') || ($sub == 'SN') || ($sub == 'SEJ'))   {
                          if ($res == 0) {
                            $merit = 18;
                          }
                          if ($res == 1) {
                            $merit = 16;
                          }
                          if ($res == 2) {
                            $merit = 14;
                          }
                          if ($res == 3) {
                            $merit = 12;
                          }
                          if ($res == 4) {
                            $merit = 10;
                          }
                          if ($res == 5) {
                            $merit = 8;
                          }
                          if ($res == 6) {
                            $merit = 6;
                          }
                          if ($res == 7) {
                            $merit = 4;
                          }
                          if ($res == 8) {
                            $merit = 2;
                          }
                          if ($res == 9) {
                            $merit = 0;
                          }
                          
                          $main_merit += $merit;
                          
                        }
    
       //to select high mark for 5th subject
                        
                        
                        else if ((($sub == 'PI') || ($sub == 'PM') || ($sub == 'PQS') || ($sub == 'PSI') || ($sub == 'HQ') || ($sub == 'MQ')) ){
                           if ($res == 0) {
                            $merit = 18;
                          }
                          if ($res == 1) {
                            $merit = 16;
                          }
                          if ($res == 2) {
                            $merit = 14;
                          }
                          if ($res == 3) {
                            $merit = 12;
                          }
                          if ($res == 4) {
                            $merit = 10;
                          }
                          if ($res == 5) {
                            $merit = 8;
                          }
                          if ($res == 6) {
                            $merit = 6;
                          }
                          if ($res == 7) {
                            $merit = 4;
                          }
                          if ($res == 8) {
                            $merit = 2;
                          }
                          if ($res == 9) {
                            $merit = 0;
                          }
    
                          $main_add_merit = $merit;
     $l[$i] = $merit;
    rsort($l);
    $arrlength = count($l);
    
    for($x = 0; $x < 1; $x++) {
     
     $main_add_merit=$l[$x];
    
     $main_add_merit;
      
                        
                          
                        }
    }
                
                    
    
    
                      else if (($sub == 'BI') || ($sub == 'TSI') || ($sub == 'PAP') || ($sub == 'PAK'))  {
                          if ($res == 0) {
                            $merit = 18;
                          }
                          if ($res == 1) {
                            $merit = 16;
                          }
                          if ($res == 2) {
                            $merit = 14;
                          }
                          if ($res == 3) {
                            $merit = 12;
                          }
                          if ($res == 4) {
                            $merit = 10;
                          }
                          if ($res == 5) {
                            $merit = 8;
                          }
                          if ($res == 6) {
                            $merit = 6;
                          }
                          if ($res == 7) {
                            $merit = 4;
                          }
                          if ($res == 8) {
                            $merit = 2;
                          }
                          if ($res == 9) {
                            $merit = 0;
                          }
    
    
                        $sum=0;
    
                          $main_add_merit1 = $merit;
                        
    
                           $y[$i] = $main_add_merit1;
                           //echo '<br>';
                           rsort($y);
    $arrlength = count($y);
    
    for($x = 0; $x < 3; $x++) {
     
     $sum += $y[$x];
    
     
      $sum;
    
    
    
                        } 
     
    
    
    
    } 
     
     
    
    }
    
    
    
    }
    
      
    
     
     $total = $main_merit+$main_add_merit;
    
    $total1 = $sum+$total; 
     }
    
    
    
        
                  
     
    
              if(!empty($firstList)){
                $firstLists = (explode(",",$firstList));
    
                $program = NULL;
    
                foreach ($firstLists as $firstList) {
                  
                  if($first=='DIP'){
                    $sql_DIP="SELECT * FROM program_diploma WHERE pg_code='$firstList'";
                    $resultDCode=mysqli_query($dbconfig3,$sql_DIP); 
                    $row=mysqli_fetch_array($resultDCode,MYSQLI_ASSOC);
    
                    if($program == NULL){       
                      if ($firstList == 'DMM') {
                        if(($BM <= 6) && ($MAT <= 6) && ($BI <= 8) && ($SEJ <= 8) &&  (($SN <= 6) || ($FIZ <= 6) || ($KIM <= 6)  || ($BIO <= 6) || ($SNT <= 6) || ($SPT <= 6) || ($PJM <= 6) || ($PJE <= 6) || ($PJA <= 6) || ($TKJ <= 6) || ($TEK <= 6 || ($LKJ <= 6)))){
                          $pgName=$row['pg_name'];
                          $program = $pgName;
                //$program = 'Diploma In Mechanical Engineering <br>';
                          $programCode = '01';
                        }else{
                          $program ='';
                        }
                      }elseif($firstList == 'DKC'){
                        if(($BM <= 6) && ($MAT <= 6) && ($BI <= 8) && ($SEJ <= 8) &&  (($SN <= 6) || ($FIZ <= 6) || ($KIM <= 6)  || ($BIO <= 6) || ($SNT <= 6) || ($SPT <= 6) || ($PJM <= 6) || ($PJE <= 6) || ($PJA <= 6) || ($TKJ <= 6) || ($TEK <= 6 || ($LKJ <= 6)))){
                          $pgName=$row['pg_name'];
                          $program = $pgName;
                //$program = 'Diploma In Chemical Engineering <br>';
                          $programCode = '01';
                        }else{
                          $program ='';
                        }
                      }elseif($firstList == 'DAA'){
                        if(($BM <= 6) && ($MAT <= 6) && ($BI <= 8) && ($SEJ <= 8) &&  (($SN <= 6) || ($FIZ <= 6) || ($KIM <= 6) || ($BIO <= 6) || ($SNT <= 6) || ($SPT <= 6) || ($PJM <= 6) || ($PJE <= 6) || ($PJA <= 6) || ($TKJ <= 6) || ($TEK <= 6 || ($LKJ <= 6)))){
                          $pgName=$row['pg_name'];
                          $program = $pgName;
                //$program = 'Diploma In Civil Engineering <br>';
                          $programCode = '01';
                        }else{
                          $program ='';
                        }
                      }elseif($firstList == 'DEE'){
                        if(($BM <= 6) && ($MAT <= 6) && ($BI <= 8) && ($SEJ <= 8) &&  (($SN <= 6) || ($FIZ <= 6) || ($KIM <= 6) || ($BIO <= 6) || ($SN <= 6) || ($SNT <= 6) || ($SPT <= 6) || ($PJM <= 6) || ($PJE <= 6) || ($PJA <= 6) || ($TKJ <= 6) || ($TEK <= 6 || ($LKJ <= 6)))){
                          $pgName=$row['pg_name'];
                          $program = $pgName;
                //$program = 'Diploma In Electric Engineering (industrial Electronic) <br>';  
                          $programCode = '01';
                        }else{
                          $program ='';
                        }
                      }elseif($firstList == 'DCS'){
                        if(($BM <= 6) && ($MAT <= 6) && ($BI <= 8) && ($SEJ <= 8) && (($SN <= 8) || ($KIM <= 6) || ($BIO <= 6) || ($SN <= 6) || ($SNT <= 6) || ($SPT <= 6) || ($PJM <= 6) || ($PJE <= 6) || ($PJA <= 6) || ($TKJ <= 6) || ($TEK <= 6) || ($LKJ <= 6) || ($FOP <= 6) || ($PDT <= 6) || ($AKP <= 6))){
                          $pgName=$row['pg_name'];
                          $program = $pgName;
                //$program = 'Diploma In Computer Science <br>';
                          $programCode = '01';
                        }else{
                          $program ='';
                        }
                      }elseif($firstList == 'DPS'){
                        if(($BM <= 6) && ($BI <= 8) && ($SEJ <= 8) && (($MAT <= 6) || ($KIM <= 6) || ($BIO <= 6) || ($SN <= 6) || ($SNT <= 6) || ($FIZ <= 6))){
                          $pgName=$row['pg_name'];
                          $program = $pgName;
                //$program = 'Diploma In Safety And Health <br>';
                          $programCode = '01';
                        }else{
                          $program ='';
                        }
                      }
                    }
    
    
    
    
    
    
                  }
    
                }
              }
                ?> 
    
    
    
    
    
    
    
    
    
    
    <tr>
                      <td class="table-plus"></td>
                      <td><?php echo strtoupper($name)?></td>
                      <td><?php echo $ic?></td>
                      <td><?php echo $aliran?></td>
                      <!--td><?//php echo strtoupper($FirstList)?></td-->
                      <!--td><?//php echo $stAppDate?></td-->
                      <td><?php echo $program?></td>
                      <td><?php echo $total?></td>
                      <td><?php echo $sum?></td>
                        <td><?php echo $total1?></td>
                         
                                      
                    </tr>
                  <?php
                      }
                  ?>
    
    
    </tbody>
                </table>
              </div>
            </div>
                
            </div>
            </form>
            <!--footer-->
            <?php include("footer.php"); ?> 
          </div>
        </div>
    
    
    
    !-- js -->
        <script src="vendors/scripts/core.js"></script>
      <script src="vendors/scripts/script.min.js"></script>
      <script src="vendors/scripts/process.js"></script>
      <script src="vendors/scripts/layout-settings.js"></script>
      <script src="src/plugins/datatables/js/jquery.dataTables.min.js"></script>
      <script src="src/plugins/datatables/js/dataTables.bootstrap4.min.js"></script>
      <script src="src/plugins/datatables/js/dataTables.responsive.min.js"></script>
      <script src="src/plugins/datatables/js/responsive.bootstrap4.min.js"></script>
      <!-- buttons for Export datatable -->
      <script src="src/plugins/datatables/js/dataTables.buttons.min.js"></script>
      <script src="src/plugins/datatables/js/buttons.bootstrap4.min.js"></script>
      <script src="src/plugins/datatables/js/buttons.print.min.js"></script>
      <script src="src/plugins/datatables/js/buttons.html5.min.js"></script>
      <script src="src/plugins/datatables/js/buttons.flash.min.js"></script>
      <script src="src/plugins/datatables/js/pdfmake.min.js"></script>
      <script src="src/plugins/datatables/js/vfs_fonts.js"></script>
      <!-- Datatable Setting js -->
      <script src="vendors/scripts/datatable-setting.js"></script>
    
    
    
    </body>
    <?php
    
    } 
    
    
    
    
    
    
     
    
    else {
      echo '<script>';  
      echo 'alert("Session expired. Please login again.")';
      //echo 'window.href("index.php")';
      echo 'window.location = "index.php"';
      echo '</script>';
    }
    ?>
    

     

  16. so , subject  is sub() and grade(res)  like above ..and i have to get merit total based on condition . the merit value is based on the grade

    1) i have to get merit for 4 main subject like in the first  if else

    2) in second if else , i have to get the 1 higher/maximum subject gred and get the merit

    3)in third if else , i have to get total merit from 3 other maximum/gred subject than in first and second if else.

    4) lastly , total 5 subject merit (4 subject from first if else +1 subject from second if else) + total merit from  3 other maximum/gred subject / sum =5+3

  17. 
                          $main_add_merit1 = $merit;
                        
    
                           $s[$i] = $main_add_merit1;
                           //echo '<br>';
                           $sum=0;
     rsort($s);
    $arrlength = count($s);
     
    
     //foreach ($s as $si){
    for($x = 0; $x < 3; $x++) {
    
    
     $sum += $s[$x];
                 }       
        
    
                      
    }

    i'got the value  3 sum . but right now , it stop the value on third student . so the fourth and after ,they getting value from third student .i only want calculate 3 first value form sorting . seems it also stop for third student . and getting looping weirdly .can you help me with that 

  18.  

     

     

                        foreach(array_combine($subjects, $grades) as $sub => $res){


                        
                      if($aliran=='S'){
                         $sql4="SELECT * FROM `qualification_result` where st_aliran='S'";
                     $result4=mysqli_query($dbconfig,$sql4);
                      $row4=mysqli_fetch_array($result4,MYSQLI_ASSOC) ;
                        //$stEmail = $row4['st_email'];
                        //$stIC = $row3['st_ic'];
                        //$aliran1 = $row4['S'];
                       


                        if ($sub == 'MAT' || $sub == 'M-T' || $sub == 'FIZ' ||$sub == 'KIM'){


                          if ($res == 0) {
                            $merit = 18;
                          }
                          if ($res == 1) {
                            $merit = 16;
                          }
                          if ($res == 2) {
                            $merit = 14;
                          }
                          if ($res == 3) {
                            $merit = 12;
                          }
                          if ($res == 4) {
                            $merit = 10;
                          }
                          if ($res == 5) {
                            $merit = 8;
                          }
                          if ($res == 6) {
                            $merit = 6;
                          }
                          if ($res == 7) {
                            $merit = 4;
                          }
                          if ($res == 8) {
                            $merit = 2;
                          }
                          if ($res == 9) {
                            $merit = 0;
                          }

                          $main_merit+= $merit;
                        } 
    //to select high mark for 5th subject
                        $high_res = min(array($res));
                        
                        if ((($sub == 'SNT') || ($sub == 'BIO') || ($sub == 'GRA') || ($sub == 'GKT') || ($sub == 'TEK') || ($sub == 'LKJ') || ($sub == 'PJA') || ($sub == 'PJE') || ($sub == 'PJM') || ($sub == 'PSS') || ($sub == 'PEE') || ($sub == 'MUL') || ($sub == 'PDT') || ($sub == 'RKB') || ($sub == 'RT') || ($sub == 'SS')) && (($sub != 'MAT') || ($sub != 'M-T') || ($sub != 'FIZ') || ($sub != 'KIM'))){
                          if ($high_res == 0) {
                            $meritAdd = 18;
                          }
                          if ($high_res == 1) {
                            $meritAdd = 16;
                          }
                          if ($high_res == 2) {
                            $meritAdd = 14;
                          }
                          if ($high_res == 3) {
                            $meritAdd = 12;
                          }
                          if ($high_res == 4) {
                            $meritAdd = 10;
                          }
                          if ($high_res == 5) {
                            $meritAdd = 8;
                          }
                          if ($high_res == 6) {
                            $meritAdd = 6;
                          }
                          if ($high_res == 7) {
                            $meritAdd = 4;
                          }
                          if ($high_res == 8) {
                            $meritAdd = 2;
                          }
                          if ($high_res == 9) {
                            $meritAdd = 0;
                          }
                          $main_add_merit = $meritAdd;
                          
                     
                        }
    else if ((($sub == 'BM')  || ($sub == 'BI') ||  ($sub == 'SEJ') || ($sub == 'PQS') || ($sub == 'PSI')|| ($sub == 'BAT')|| ($sub == 'PI'))){//3 other subject
                          if ($high_res == 0) {
                            $meritAdd = 18;
                          }
                          if ($high_res == 1) {
                            $meritAdd = 16;
                          }
                          if ($high_res == 2) {
                            $meritAdd = 14;
                          }
                          if ($high_res == 3) {
                            $meritAdd = 12;
                          }
                          if ($high_res == 4) {
                            $meritAdd = 10;
                          }
                          if ($high_res == 5) {
                            $meritAdd = 8;
                          }
                          if ($high_res == 6) {
                            $meritAdd = 6;
                          }
                          if ($high_res == 7) {
                            $meritAdd = 4;
                          }
                          if ($high_res == 8) {
                            $meritAdd = 2;
                          }
                          if ($high_res == 9) {
                            $meritAdd = 0;
                          }
                          $main_add_merit1 = $meritAdd;
                          //echo $main_add_merit1;
                          //sort ($main_add_merit1);

                          $s[$i] = $main_add_merit1;
    $i++;
                    $s[$i];
                    // echo '<br>';
    rsort($s);
    $arrlength = count($s);
    for($x = 0; $x < 3; $x++) {
     
    echo  $s[$x];
     // echo '<br>';

      

    }
        
                      } $total =$main_merit+$main_add_merit;
    }


     }
     } 

     

    is the way i put loop is wrong? because it get looping everytime and user does not get their result . i have to display merit for 5 main subject and it done .but when i have to display sum of 3 other subject,the looping get me wrong .

    error.PNG

×
×
  • 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.