Guest User

Untitled

a guest
Jun 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.02 KB | None | 0 0
  1. <?php session_start(); ?>
  2. <?php require('includes/dbconnect.php'); ?>
  3. <?php require 'includes/header.inc.php'; ?>
  4.  
  5. <?php
  6.  
  7.          
  8.        
  9.         $matric_no = mysql_real_escape_string($_POST['matric_no']) ;
  10.  
  11.  
  12.      if ($_POST['matric_no'] == "")
  13.  
  14. {
  15.     echo"<div id=\"contentRight\">";
  16.     echo"<idv id=\"msg\">" ;
  17.    
  18.         echo "You didn't enter a <span style=\"color:red\">Matric Number</span>";
  19.        
  20.     echo"</div>" ;
  21.     echo"</div>" ;
  22.         exit();
  23. }
  24.  
  25.         $query = "SELECT matric_no
  26.                  
  27.                  FROM students
  28.                  
  29.                  WHERE matric_no = '$_POST[matric_no]'";
  30.                  
  31.                  
  32.         $result = mysql_query($query) ;
  33.          
  34.         $duplicates = mysql_num_rows($result);
  35.        
  36.         if ($duplicates < 1)
  37. {
  38.    
  39.     echo"<div id=\"contentRight\">";
  40.    
  41.     echo"<idv id=\"msg\">" ;
  42.  
  43.         echo "You dont have a record for <span style=\"color:red\">$matric_no</span>" ;
  44.        
  45.     echo"</div>" ;
  46.     echo"</div>" ;
  47.         exit();
  48. }
  49.  
  50.        
  51. $result = mysql_query("SELECT matric_no, first_name, last_name, other_name
  52.                       FROM students
  53.                       WHERE matric_no = '".mysql_real_escape_string($_POST['matric_no'])."'") or die(mysql_error());
  54.          
  55.          
  56.          
  57.  
  58.           $number_cols = mysql_num_fields($result) ;
  59.          
  60.           echo "<div id=\"contentRight\">" ;
  61.          
  62.         echo "<span class=\"header\">";
  63.          
  64.           echo "<p><b>Matric Number: ".mysql_real_escape_string($_POST['matric_no'])."</b></p>";
  65.        
  66.             echo "<table border = 1 , cellspacing = 0 , cellpadding = 2 bgcolor = lemonchiffon  >\n";
  67.            
  68.            
  69.             echo "<tr align=center>\n";
  70.            
  71.            
  72.             for ($i=0; $i<$number_cols; $i++)
  73.            
  74.            
  75.             {
  76.            
  77.            
  78.             echo "<th>" . mysql_field_name($result, $i). "</th>\n";
  79.            
  80.            
  81.             }
  82.            
  83.            
  84.             echo "</tr>\n";
  85.            
  86.                     //end table header
  87.                     //layout table body
  88.  
  89.  
  90.             while ($row = mysql_fetch_row($result))
  91.  
  92.  
  93.             {
  94.  
  95.            
  96.             echo "<tr align=center>\n";
  97.            
  98.            
  99.             for ($i=0; $i<$number_cols; $i++)
  100.            
  101.            
  102.             {
  103.  
  104.             echo "<td>";
  105.  
  106.  
  107.             if (!isset($row[$i])) //test for null value
  108.  
  109.            
  110.             {echo "NULL";}
  111.            
  112.             else
  113.  
  114.             {echo $row[$i];}
  115.  
  116.             echo "</td>\n";
  117.            
  118.             }
  119.  
  120.             echo "</tr>\n";
  121.  
  122.             }
  123.            
  124.             echo "</table>";
  125.             echo"</span>" ;
  126.            
  127.             echo"</div>";
  128.            
  129.              
  130.  
  131. ?>
  132.  
  133.  
  134.    <br />
  135.     <?php
  136.    while($row = mysql_fetch_array($result)){
  137.        ?>
  138.    
  139.    <div id="contentRight">
  140.  
  141.       <p>
  142.  
  143.    Select the Score options you will like to update:
  144.    
  145.    <form action="student_update2.php" method="post">
  146.    
  147.  
  148.        
  149.         <ul>
  150.         <li>Matric Number: &nbsp;<input type="text" name="matric_no"> </li><br /><br />
  151.         <li>First Name: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="first_name"> </li><br /><br />
  152.         <li>Last Name: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="last_name"> </li><br /><br />
  153.         <li>Other Names:&nbsp; &nbsp;&nbsp;<input type="text" name="other_name" value="<?php echo $row1['other_name'] ; ?>"</li> <br /><br />
  154.                        
  155.        
  156.    <input type="submit" name="submit" value="Update" />
  157.                        
  158.    <input type="hidden" name="submitted" value="TRUE" />
  159.              
  160.     <input name="Reset" type="reset" value="Reset" />
  161.                  
  162.                  
  163.        
  164.       </ul>
  165.     </div>
  166.  
  167.   </div>  
  168.   </form>  
  169.  
  170.  <?php
  171.    }            
  172.   require 'includes/footer.php'; ?>
Add Comment
Please, Sign In to add comment