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 PHP program to create a simple calculator that can accept two numbers and perform operations like add, subtract, multiplication and divide (using Self Processing form)

Write an Ajax program to print the content of the myfile.dat. This code asks the user to click a button, fetches data from the server using Ajax techniques and displays that data in the same web page as the button without refreshing the page