We Blab Programs
We Blab Programs
We Blab Programs
<html>
<!-- 2b.html -->
<head><title>Program 12</title></head>
<body>
<form action="12b.php" method="post">
Enter Name of the person <input type="text" name="name">
<input type=submit>
</form>
</body>
</html>
<html>
<!-- 2b.php -->
<head><title>Search Result </title></head>
<body>
<h3>Search Result </h3>
<hr>
<?php
$link=mysql_connect("localhost","root","");
mysql_select_db("mca");
$n=$_POST["name"];
print "Entered Name is $n \n";
$var=mysql_query("SELECT * FROM contact WHERE name like '%$n
%'");
echo"<table border size=1>";
echo"<tr><th>Name</th> <th>Address 1</th> <th>Address 2</th>
<th>E-mail</th></tr>";
while ($arr=mysql_fetch_row($var))
{
echo "<tr><td>$arr[0]</td> <td>$arr[1]</td> <td>$arr[2]</td>
<td>$arr[3]</td> </tr>";
}
echo"</table>";
mysql_free_result($var);
mysql_close($link);
?>
<hr>
<form action="2b.html">
<input type="submit" value="Back">
</form>
</body>
</html>
3. Write a PHP program to read student data from an XML file and
store into the MYSQL database. Retrieve and display.
<?php
3a.php
$xmlstr = <<<XML
<? Xml version=1.0 standalone=yes?>
<student_details>
<student>
<stud_name> ABCD </stud_name>
<stud_usn> 1234 </stud_usn>
<stud_branch> MCA </stud_branch>
</student>
<student>
<stud_name> EFGH </stud_name>
<stud_usn> 5678 </stud_usn>
<stud_branch> MBA </stud_branch>
</student>
</student_details>
XML;
?>
-------------------------------------------------------------<?php
3b.php
include 3a.php;
$xml = new SimpleXMLElement($xmlstr);
echo $xml->getName() . <br />;
echo multiple values: <br />;
$link=mysql_connect(localhost,root,);
mysql_select_db(mca);
foreach ($xml->student as $student)
{
echo $student->stud_name . <br />;
echo $student->stud_usn . <br />;
echo $student->stud_branch . <br />;
echo <br />;
$t=mysql_query(insert into student values($student>stud_name,$student->stud_usn,$student->stud_branch));
}
-------------------------------------------------------------<html> <head>
3c.html
<title> A program to get values from database
</title></head>
<body>
@name = bk.name
@descp = bk.description
@price = bk.price %>
<tr>
<td> <%= @id %></td>
<td><%= @name %> </td>
<td><%= @descp %></td>
<td> <%= @price %></td>
/tr>
<% end %>
</table> </body></html>
OUTPUT: