DATA TRANSFER BETWEEN HETEROGENEOUS DATASOURCEP


PHP
Step 1: Open new database in MS Access.
Step 2: Create a table with necessary fields.
Step 3: Go to control panel  >> Administrative Tools >> Data source(ODBC) >> System DSN.
Step 4: Select the appropriate MS Access driver and give the dsn name.
Step 5: Select the database to be configured and click ok.
Step 6: In the account page , the fees is collected by entering register number and amount.
Step 7: The fees details is inserted into the table.
Step 8: The student fees history shows the total fees being collected from each student by
            fetching the  records  from  table .
Step 9: Run the program in browser.

PHP CONSTRUCTS
1.      Setting the connection to data source.
odbc_connect(“dsn name”,”username”,”password”);

2.      Executing query
odbc_exec(connection variable,”sql statement”);

3.      Executing the records
odbc_fetch_row(execution variable);

4.      Refering each field value
 odbc_result(execution variable,”field name”);
PROGRAM
Home.php
<html>
<body bgcolor="pink"><br><center>
<form name="name" method="get">
<h2><font color=green>ENGINEERING COLLEGE</font></H2>
<h3><font color="green">CAMPUS MANAGEMENT SYSTEM</font></h3>
<image src="packard-campus-library-of-c.jpg">
<h3><a href="login.php"><font color="maroon">STAFF LOGIN</font></a><br><br>
<a href="login.php"><font color="maroon">STUDENTS LOGIN</font></a><br><br>
<a href="fee1.php"><font color="maroon">ACCOUNTANT LOGIN</font></a></h3>
</center></form></body></html>
Fee1.php
<?php
Session_start();
$_SESSION['fee']=0;
header("location:fee.php");
?>
Fee.php
<html>
<body bgcolor=pink>
<center>
<form name=loginn method="post" action="collection.php">
<font color="green" size=5><b>JYOTHI EGINEERING COLLEGE<b></font></br></br></br>
<image src ="packard-campus-library-of-c.jpg";</br></br>
REG.NO <input type=text name=regno><br><br>
FEE &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type=text name=fee><br></br>
<input type=submit value=Calculate><br>
<a href="total.php"><b>Total Fees collected<b></a></br></br>
<a href="details.php"><b>View<b></a></center>
</form>
</body>
</html>
Collection
<html>
<body>
<?php
session_start();
$amt=$_POST['fee'];
$reg=$_POST['regno'];
include("fee.php");
if(!isset($_SESSION['fee']))
{
$_SESSION['fee']=$amt;
}
else {
$n = $_SESSION['fee'];
$n1=$n+$amt;
$_SESSION['fee']=$n1;
}
$con=odbc_connect("dsn1","","");
$r=odbc_exec($con,"select * from details where regno='".$reg."'");
if(!(odbc_fetch_row($r)))
$re=odbc_exec($con,"insert into details values('".$reg."',".$amt.")");
else
{
$fee1=odbc_result($r,"fee");
$fee1=$fee1+$amt;
$re=odbc_exec($con,"update details set fee=".$fee1." where regno='".$reg."'");
}
echo "<h2>fees collected successfully<h2>";
?>
</body>
</html>

Total
<?php
session_start();
include("fee.php");
$tot=$_SESSION['fee'];
echo "<h2>You Have Collected RS.".$tot ;
?>
Details
<html>
<body bgcolor=pink>
<center>
<form name=loginn method="post" action="collection.php">
<font color="green" size=6><b>ENGINEERING COLLEGE</b></font></br></br></br>
<image src="packard-campus-library-of-c.jpg";</br></br></br></br>
<font color="pale green" size=6><b>Total fees collected</b></font>
<?php
$con=odbc_connect("dsn1","","");
$r=odbc_exec($con,"select * from details");
echo "<table border=1><tr><td>Reg_No</td><td>Total Fee</td></tr>";
while(odbc_fetch_row($r))
{
echo "<tr><td>" .odbc_result($r,"regno")."</td>";
echo "<td>" .odbc_result($r,"fee")."</td></tr>";
}
?>
</body>
</html>

0 comments: