A college has given roll number to each student, The roll number is six digit number where first two digits are faculty(B.Sc., BCA, BA) third digit is year (Ist(1), IInd(2) and IIIrd(3)) and last three digit are actual number. Write PHP script to accept a number and print faculty, year and roll number of student.(e.gRollno=BC1004,faculty=BCA, year=1st,rollno=004)

Student.html

<html>
<body>
<form method=get action="student.php">
Enter  <input type=text name="a"><br>
<input type=submit value=submit>
</form>
</body>
</html>

//Student.php

<?php
$a=$_GET['a'];
if(ereg("^BC|A|S([1-3])([0-9][0-9][0-9])$",$a))
{
echo"Roll no = ".substr($a,3)."<br>";
   $year=substr($a,2,1);
if($year=='1')
echo"Year = 1st <br>";
if($year=='2')
echo"Year = 2nd <br>";
if($year=='3')
echo"Year = 3rd <br>";
  $fac=substr($a,0,2);
if($fac=='BA')
echo"Faculty = BA";
if($fac=='BC')
echo"Faculty = BCA";
if($fac=='BS')
echo"Faculty = B.Sc.";
}
else
{
echo"Invalid ";
}
?>

Comments

Popular posts from this blog

Create an XML file which gives details of books available in “ABC Bookstore” from following categories. 1)      Technical 2)      Cooking 3)      Yoga And elements in each category are in the following format.     …….     …….     ……. Save the file as “Book.xml” Create an application that reads “Book.xml” file into simple XML object. Display attributes and elements. (Hint:- Use simple_xml_load_file() function). 

Write a simple PHP program which implements Ajax for addition of two numbers

Consider the following relational database: Project (P_Group_No, Project_Title) Student (Seat no, Name, Class, P_Group_No) Write a PHP script to accept project title and display list of students those who are working in a particular project.