Wednesday, 27 December 2017

AWT-Slip26



1). 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>
<body>
<form action=slip26.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>

slip26.Php 

<?php

$rno=$_GET['rno'];
$s_name=$_GET['s_name'];
$cls=$_GET['cls'];

$con=@mysql_connect("localhost","root","");
$d=mysql_select_db("archana",$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();
?>

                                                                                                                                                                               
2) Write a script to solve following questions (Use “Book.xml” file)
a) Create a DOM Document object and load this XML file.
b) Get the output of this Document to the browser
c) Save this [. XML] document in another format i.e. in [.doc]
           d) Write a XML program to print the names of the books available in “Book.xml” file.      
abcbook.xml
<?xml version="1.0"?>
<ABCBOOK>
        <Technical>
        <BOOK>
        <Book_PubYear>ABC</Book_PubYear>
        <Book_Title>pqr</Book_Title>
        <Book_Author>400</Book_Author>
        </BOOK>
        </Technical>    
    <Cooking>
        <BOOK>
        <Book_PubYear>BBC</Book_PubYear>
        <Book_Title>pPr</Book_Title>
        <Book_Author>500</Book_Author>
        </BOOK>
    </Cooking>    
    <Yoga>
        <BOOK>
        <Book_PubYear>CBC</Book_PubYear>
        <Book_Title>pRr</Book_Title>
        <Book_Author>600</Book_Author>
        </BOOK>
    </Yoga>
</ABCBOOK>
dombook.php
<?php      
        $dom=new DomDocument();
        $dom->load("abcbook.xml");
        print $dom->saveXML()."<br>";
        print $dom->save("newfile.doc");
?>