2017-02-06 6 views
0

Ich möchte, wenn die Mitarbeiter auf die Anwendungsseite gehen, um die Liste der Anwendung von Studenten zu sehen. Es wird nur der Status von apply_status = 'PENDING' angezeigt. Status, der bereits zuvor genehmigt wurde, wird auf der Seite nicht angezeigt. ................................................. ...............................Zeilen nach Feldern in Mysql filtern

Dies ist mein Code, wenn nur der apply_status = 'PENDING' nur angezeigt wird auf der Seite. ... füge ich die if else Aussage hinzu ... aber funktioniert nicht. wenn mehrere apply_status = genehmigt sind. Es wird nicht die ausstehende angezeigt. Aber wenn es keinen apply_status = aprroved gibt. Es wird alle Anwendungen angezeigt.

<?php 
    include("connection.php"); 
    $sql="SELECT * FROM application"; 
    $record = mysqli_query($con, $sql) or die ("error".mysqli_error($con)); 
    $apply = mysqli_fetch_assoc($record); 

    $status1 = $apply["apply_status"]; 

    if ($status1 == "APPROVED") { 
     echo "<br>"; 
     echo "No application from student yet.<br>"; 
     echo "<br>"; 
    } 

    else { 

    echo "<table border='1'><tr> 

    <td><strong>Student ID</strong></td> 
    <td><strong>Student Name</strong></td> 
    <td><strong>Kelompok</strong></td> 
    <td><strong>Block</strong></td> 
    <td><strong>Level</strong></td> 
    <td><strong>House</strong></td> 
    <td><strong>Status</strong></td> 


    </tr>"; 
    $i=0; 
    while ($ww=mysqli_fetch_array($query)) 
    { 
     if ($i%2==0) 
      $class="evenRow"; 
     else 
      $class="oddRow"; 

     $id=$ww[0]; 
     $studentid=$ww[1]; 
     $name=$ww[2]; 
     $kelompok=$ww[8]; 
     $block=$ww[9]; 
     $level=$ww[10]; 
     $house=$ww[11]; 
     $status=$ww[14]; 



    echo '<tr> 
     <input type="hidden" name="applyid['.$i.']" value="'.$id.'"/> 
     <td>'.$studentid.'</td> 
     <td>'.$name.'</td> 
     <td>'.$kelompok.'</td> 
     <td>'.$block.'</a></td> 
     <td>'.$level.'</td> 
     <td>'.$house.'</td> 
     <td> 
      <input type="checkbox" name="status['.$i.']" value="approved" checked> APPROVED <br> 
     </td> 
     </tr>'; 
    $i++; 
    } 

    echo '</table>'; 

    } 

Ich denke, der Fehler bei der else if-Anweisung ist, aber ich weiß nicht, wie die apply_status zu unterscheiden = genehmigt und apply_status = anhängig.

+0

'print_r ($ gelten);' und schauen in die Ausgabe gedruckt ... – Naga

Antwort

0

die Sie interessieren, Denken Sie daran,

$status1 = $apply["apply_status"]; 

sollte Teil Schleife sein, gibt es kann Zeilen, die es hat.

<?php 
    include("connection.php"); 
    $sql="SELECT * FROM application"; 
    $record = mysqli_query($con, $sql) or die ("error".mysqli_error($con)); 
    $i=0; 
    $number_of_rows = mysql_num_rows($record); 

    if ($number_of_rows == 0) { 
      echo "<br>"; 
      echo "No application from student yet.<br>"; 
      echo "<br>"; 
    } else { 
     while ($ww=mysqli_fetch_array($record)) 
    { 

    echo "<table border='1'><tr> 

    <td><strong>Student ID</strong></td> 
    <td><strong>Student Name</strong></td> 
    <td><strong>Kelompok</strong></td> 
    <td><strong>Block</strong></td> 
    <td><strong>Level</strong></td> 
    <td><strong>House</strong></td> 
    <td><strong>Status</strong></td> 


    </tr>"; 


     if ($i%2==0) 
      $class="evenRow"; 
     else 
      $class="oddRow"; 

     $id=$ww[0]; 
     $studentid=$ww[1]; 
     $name=$ww[2]; 
     $kelompok=$ww[8]; 
     $block=$ww[9]; 
     $level=$ww[10]; 
     $house=$ww[11]; 
     $status=$ww[14]; 



    echo '<tr> 
     <input type="hidden" name="applyid['.$i.']" value="'.$id.'"/> 
     <td>'.$studentid.'</td> 
     <td>'.$name.'</td> 
     <td>'.$kelompok.'</td> 
     <td>'.$block.'</a></td> 
     <td>'.$level.'</td> 
     <td>'.$house.'</td> 
     <td> 
      <input type="checkbox" name="status['.$i.']" value="approved" checked> APPROVED <br> 
     </td> 
     </tr>'; 
    $i++; 
    } 

    echo '</table>'; 


    } 
+0

danke soviel !!! es ist Arbeit!! aber meine Ausgabe sieht so aus -> "Noch keine Bewerbung von Schüler. und Tabelle des Schülers zeigen, dass apply_status = ausstehend" es sieht diese zwei Ergebnisse von wenn sonst an. Meine Tabellenanwendung hat 2 Studenten, die eine apply_status = genehmigt und eine andere apply_status = ausstehend ist. also ich möchte, wenn alle apply_status = genehmigt, so wird es "keine Bewerbung von Studenten noch zeigen". Wenn es jedoch einen anderen Schüler gibt, der apply_status = pending, wird nur diese Schüleranwendung angezeigt. –

+0

Ich würde direkt auf die Abfrage $ sql = "SELECT * FROM' application' WHERE 'apply_status' = 'PENDING'"; dann, wenn MYSQL_num_rows zurück> 0 Zeilen zeigen sonst zeige "Keine Anwendung von Studenten noch.
" – flakerimi

+0

@MaryamNabilah Überprüfen Sie meine Bearbeitung – flakerimi

0

Im nicht "Personal" Zustand im Code gefunden ,,

include("connection.php"); 

$sql="SELECT * FROM application"; 

if($staff){ 
$sql = $sql. " WHERE apply_status = 'PENDING'"; 
}else{ 
$sql = $sql. " WHERE apply_status = 'APPROVED'"; 
} 
Verwandte Themen