Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "registration";
- $conn = new mysqli($servername, $username, $password, $dbname);
- //Create Connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT id,year FROM student";
- $result = $conn->query($sql);
- if (mysqli_num_rows($result) > 0)
- {
- // output data of each row
- $rowcount=mysqli_num_rows($result);
- while($array = mysqli_fetch_assoc($result))
- {
- $mainId[]=$array["id"];
- $mainYear[]=$array["year"];
- }
- }
- else
- {
- echo "0 results";
- }
- $sub=date('M Y');
- echo "\n";
- $presentYear=date('Y'); //2018
- $presentMon=date('m'); //Sepetember 09
- echo $presentMon;
- echo $presentYear;
- //Calculating present year for all the students
- echo $rowcount; //Number of rows in sql result
- $row=4;
- echo "<br>".$presentYear."<br>";
- echo "Main year is ".$mainYear[0]."<br>";
- function calcuateonemonth($id)
- {
- if($GLOBALS['presentMon']>=06)
- {
- echo "ID having ".$GLOBALS['temp']." is Firstyear <br>";
- }
- else
- {
- echo "ID having ".$GLOBALS['temp']." is Having Error <br>";
- }
- }
- function calcuatetwomonth($id)
- {
- echo $id;
- if($GLOBALS['presentMon']>=06)
- {
- echo "ID having ".$GLOBALS['temp']." is Secondyear <br>";
- }
- else
- {
- echo "ID having ".$GLOBALS['temp']." is Firstyear <br>";
- }
- }
- function calcuatethreemonth($id)
- {
- if($GLOBALS['presentMon']>=06)
- {
- echo "ID having ".$GLOBALS['temp']." is Thirdyear<br>";
- }
- else
- {
- echo "ID having ".$GLOBALS['temp']." is Secondyear<br>";
- }
- }
- function calcuatefourmonth($id)
- {
- if($GLOBALS['presentMon']>=06)
- {
- echo "ID having ".$GLOBALS['temp']." is Fourthyear<br>";
- }
- else
- {
- echo "Thirdyear";
- }
- }
- function calcuatefifthmonth($id)
- {
- if($GLOBALS['presentMon']<06)
- {
- echo "ID having ".$GLOBALS['temp']." is Thirdyear<br>";
- }
- else
- {
- echo "ID having ".$GLOBALS['temp']." is Having Error <br>";
- }
- }
- for($i=0;$i<$rowcount;$i++)
- {
- $temp=$mainId[$i];
- if($presentYear==$mainYear[$i])
- {
- calcuateonemonth($i);
- }
- else if($presentYear==$mainYear[$i]+1)
- {
- calcuatetwomonth($i);
- }
- else if($presentYear==$mainYear[$i]+2)
- {
- calcuatethreemonth($i);
- }
- else if($presentYear==$mainYear[$i]+3)
- {
- calcuatefourmonth($i);
- }
- else if($presentYear==$mainYear[$i]+4)
- {
- calcuatefifthmonth($i);
- }
- else
- {
- echo "ID having ".$GLOBALS['temp']." is Having Error <br>";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment