lundi 28 mars 2016

php if statement error. when enter nothing it gives error that Enter Form# or Name to search [on hold]

I m facing problem. when i enter nothing it gives error that Enter Form# or Name to search. but when i enter wrong name or form number it gives no error just stay blank

<?php 
if(isset($_POST['submit'])){ 
    if (!empty($_POST['search'])) { 
        if($name = $_POST['search']){ 
            $sql = "SELECT * FROM students WHERE form_num = '$name' OR name = '$name'"; 
            $run = mysqli_query($conn,$sql); 
            while($rows = mysqli_fetch_assoc($run)) { 
                echo ' '.$rows['roll_num'].' '.$rows['form_num'].' '.$rows['name'].' '.$rows['f_name'].' '.$rows['course'].' '.$rows['adm_date'].';
            } 
        }else{ 
            echo '<div class="alert alert-danger">No Record Found</div>';
        } 
    }else{ 
        echo '<div class="alert alert-danger">Enter Form# or Name to search.</div> '; 
    } 
}
?>

Aucun commentaire:

Enregistrer un commentaire