TY_BCA_AWT_SLIP 26_1



26.  Write a PHP script to accept student details(rno, name, class) and store them in student table (Max 10) , print them in sorted order of name on the browser in table format



html file :

<html>

<body>

<form action=Que26.php method=GET>

enter student roll no :<input type=text name=rno><br>

enter student name : <input type=text name=s_name><br>

enter class : <input type=text name=cls><br>

<input type=submit name=submit value=submit >

</form>

</body>

</html>

Php file :

<?php

<?php

$rno=$_GET['rno'];

$s_name=$_GET['s_name'];

$cls=$_GET['cls'];



$con=mysql_connect("localhost","root","");

$d=mysql_select_db("bca_programs",$con);

$q=mysql_query("insert into stud values($rno,'$s_name','$cls')");



$q1=mysql_query("select * from stud order by sname");

echo "<table>";

echo "<tr><td>Roll no.</td><td>Name</td><td>Class</td></tr>";



while($row=mysql_fetch_array($q1))

{
  echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td></tr>";

}

echo "</table>";

mysql_close();

?>

No comments:

Post a Comment

Note: only a member of this blog may post a comment.