Jump to content

phpYESvice

New Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by phpYESvice

  1. Hello Php Friends,

    I have this search code, it wents well but i want to add and echo or maybe a script that woul tell "NO RESULTS FOUND" in case the search does not found data in the database.
    Please anyone can help.

    include 'Connect.php';
     //Connect to MySQL Server
    mysql_connect($host, $dbusername, $dbpassword);
     //Select Database
    mysql_select_db($dbname) or die(mysql_error());
     // Retrieve data from Query 
    
     $first_name = $_GET['first_name'];
     // Escape User Input to help prevent SQL Injection
    $first_name = mysql_real_escape_string($first_name);
    
    $query = "SELECT * FROM student_information WHERE first_name = '$first_name'";
    $qry_result = mysql_query($query) or die(mysql_error());
      
    $display_string = "<table border='1' cellpadding='10' cellspacing='1' align='center'>";
    $display_string .= "<tr align='center'>";
    $display_string .= "<th>LR Number</th>";
    $display_string .= "<th>F i r s t   N a m e</th>";
    $display_string .= "<th>L a s t   N a m e</th>";
    $display_string .= "<th>Grade</th>";
    $display_string .= "<th>Section</th>";    
    $display_string .= "<th>View</th>";  
    $display_string .= "<th>Update</th>";
    $display_string .= "<th>Delete</th>";
    $display_string .= "</tr>";
    // Insert a new row in the table for each person returned
    while($row = mysql_fetch_array($qry_result)){
     $display_string .= "<tr>";
     $display_string .= "<td>$row[LRN]</td>";
     $display_string .= "<td>$row[first_name]</td>";
     $display_string .= "<td>$row[last_name]</td>";
     $display_string .= "<td>$row[grade]</td>";
     $display_string .= "<td>$row[section]</td>";
     $display_string .= "<td><a href='View_Profile.php?id=$student_id'>View</a> </td>";
     $display_string .= "<td><a href='Admin_Edit_Student_Info.php?id=$student_id'>Update</a></td>";
     $display_string .= "<td><a href='Delete.php?id=$student_id'>Delete</a></td>";
    }
    $display_string .= "</table>";
    echo $display_string;
    ?>
    
    Kindly tell me what codes i am missing and where exactly to put it.
  2. hello Php Freaks,

     

    i have manage to make a search box and view the student name listed on the database with a link VIEW, EDIT, DELETE on the left side. 

    My problem is i wanted that when i click the VIEW it must direct to a specific student which name appeared on the right side.

     

    This is my ajax.php code.

    $display_string = "<table border='1' cellpadding='10' cellspacing='1' align='center'>";
    $display_string .= "<tr align='center'>";
    $display_string .= "<th>LR Number</th>";
    $display_string .= "<th>F i r s t   N a m e</th>";
    $display_string .= "<th>L a s t   N a m e</th>";
    $display_string .= "<th>Grade</th>";
    $display_string .= "<th>Section</th>";    
    $display_string .= "<th>View</th>";  
    $display_string .= "<th>Update</th>";
    $display_string .= "<th>Delete</th>";
    $display_string .= "</tr>";
    
    // Insert a new row in the table for each person returned
    while($row = mysql_fetch_array($qry_result)){
     $display_string .= "<tr>";
     $display_string .= "<td>$row[LRN]</td>";
     $display_string .= "<td>$row[first_name]</td>";
     $display_string .= "<td>$row[last_name]</td>";
     $display_string .= "<td>$row[grade]</td>";
     $display_string .= "<td>$row[section]</td>";
     $display_string .= "<td><a href='View_Profile.php?userID=$row[student_id]'>View</a> </td>";
    $display_string .= "<td><a href='Admin_Edit_Student_Info.php?userID=$row[student_id]''>Update</a></td>";
    $display_string .= "<td><a href='Admin_Delete_Student.php?userID=$row[student_id]''>Delete</a></td>";
     $display_string .= "</tr>"; 

    and this is the Student_home.php

                <p align="left"> </p>
                <p align="left"><span class="stylebig">LEARNERS INFORMATION</span></p>
              </blockquote>
            <table width="85%"  align="center">
              <tr class="stylesmall">
                <td height="50" align="left" valign="middle" class="style3 style8"> LRN</td>
                <td align="left" valign="middle" class="style8"> </td>
                <td align="left" valign="middle" class="style8"> </td>
                <td class="style8"> </td>
              </tr>
              
              <tr class="stylesmall">
                <td width="142" height="50" align="left" valign="middle" class="style8">First Name</td>
                <td width="177" align="left" valign="middle" class="style8"> </td>
                <td width="151" align="left" valign="middle" class="style8">Last Name</td>
                <td width="159" class="style8"> </td>
              </tr>
              <tr class="stylesmall">
                <td width="142" height="50" align="left" valign="middle" class="style8">Gender</td>
                <td align="left" valign="middle" class="style8"> </td>
                <td align="left" valign="middle" class="style8">Date Of Birth</td>
                <td class="style8"> </td>
              </tr>
              <tr class="stylesmall">
                <td width="142" height="50" align="left" valign="middle" class="style8">Grade</td>
                <td align="left" valign="middle" class="style8">        
                <td align="left" valign="middle" class="style8">Contact No</td>
                <td class="style8"> </td>
              </tr>
    
              <tr class="stylesmall">
                <td width="142" height="50" align="left" valign="middle" class="style8">Primary Email</td>
                <td align="left" valign="middle" class="style8"> </td>
                <td align="left" valign="middle" class="style8">Secondary Email</td>
                <td class="style8"> </td>
              </tr>
              <tr align="left" valign="middle" class="stylesmall">
                <td width="142" height="50" class="style8">Address</td>
                <td class="style8">        
              <tr align="left" valign="middle" class="stylesmall">
                <td width="142" height="50" class="style8">Description</td>
                <td class="style8">        
                <td class="style8"></td
            >
              </tr
        
      >
            </table>
          </div>
    

    i think i miss some lines of codes in the target page (Student_home.php).

    Please i am a newly practicing php coder. Help me clarify lines which i have mistaken and how to replace/correct/insert on the proper place.

    God bless everyone,

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