Showing posts with label simple example for php with mysql. Show all posts
Showing posts with label simple example for php with mysql. Show all posts

PHP WITH MYSQL




file name:      stu.html

<html>
<head>
<link rel ="stylesheet" type="text/css"href="stu.css">

<form action="mark1.php" method="post">

<title>Student marklist</title>
<body>
<table border="1">
<th colspan="2">  Student mark list</th>


<tr>   <td>Rollno</td> <td><input type="text" name="regno"></td>
<tr>    <td>Name</td> <td><input type="text" value="" name="nam" ></td>   
<tr>    <td>SPM</td> <td><input type="text" value="" name="su1"></td>   
<tr>    <td>SQM</td> <td><input type="text" value="" name="su2"></td>   
<tr>    <td>MW</td> <td><input type="text" value="" name="su3"></td>
<tr>    <td>DW</td> <td><input type="text" value="" name="su4"></td>
<tr>    <td>MC</td> <td><input type="text" value="" name="su5"></td>
<tr><th colspan="2"    <td><input type="submit" name="submit" value="submit"></td> </tr>
</table>


</body>
</head>



file name:    stu.css


th
{
background-color:#d0e4fe;
color:#0000ff;
font-size:20px;
padding-top:25px;

}

body
{
background-color:#200000;
color:#00000f;

}


td
{
background-color:#00ff00;
font-size:20px;


}


file name:  mark1.php

<!DOCTYPE html>
<html>
<body>

<?php
echo "MARK list"; echo "</br>";

echo "---------"; echo "</br>";
$roll="11CA013";

$name="karthick";


$sub1=80;
$sub2=81;
$sub3=82;
$sub4=83;
$sub5=84;


echo "Roll No.:  ".$roll;echo "</br>";

echo "Name    :".$name;echo "</br>";
echo "SPM     :".$sub1; echo "</br>";
echo "SQM     :".$sub2; echo "</br>";
echo "MW      :".$sub3; echo "</br>";
echo "DW      :".$sub4; echo "</br>";
echo "MC      :".$sub1;echo "</br>";


?>

</body>
</html>



file name:  mark1.css


th
{
background-color:#d0e4fe;
color:#0000ff;
font-size:20px;
padding-top:25px;

}

body
{
background-color:#f0f0ff;
color:#00000f;

}


td
{
background-color:#fff0f0;
font-size:20px;


}


file name:  result.html
<html>
<head>
<link rel ="stylesheet" type="text/css"href="stu.css">

<form action="result.php" method="post">

<title>Result</title>
<body>
<table border="1">
<th colspan="2">  RESULT</th>


<tr>  <td>Enter Rollno</td> <td><input type="text" name="regno"></td>

<tr><th colspan="2"    <td><input type="submit" name="submit" value="Get"></td> </tr>
</table>


</body>
</head>


filename:  result.php

<!DOCTYPE html>
<html>
<body>
<?php

$res=$_POST['regno'];

mysql_connect("localhost","root","") or die("server connection error");

mysql_select_db("mydata") or die("DB connection error");

$qry=mysql_query("select * from tab1 where Reg='$res'") or die("query error");


while($w=mysql_fetch_array($qry))
{
echo "Reg.No: ".$w['Reg']."<br>";
echo "Name  : ".$w['name']."<br>";
echo "------------------<br>";
echo "SPM   : ".$w['SPM']."<br>";
echo "SQM   : ".$w['SQM']."<br>";
echo "MW    : ".$w['MW']."<br>";
echo "DW    : ".$w['DW']."<br>";
echo "MC    : ".$w['MC']."<br>";
echo "-----------------<br>";
echo "Total : ".$w['Total']."<br>";
echo "Avg   : ".$w['Avg']."<br>";

}



?>

</body>
</html> 



mysql database



















Your IP Address is:

Browser: