<?php
// mysql Connection
mysql_connect("127.0.0.1","root","")
or
die("Server Problem");
// mysql database connection
mysql_select_db("DanishDB")
or
die("Database Problem");
if(isset($_POST['Submit']))
{
$query="create table role (role_id int auto_increment primary key ,roleName varchar(50) )";
$result=mysql_query($query);
if($result)
{
echo "Table creared..";
}
else
{
echo "Table not creared..";
}
}
if(isset($_POST['Insert']))
{
if($_POST["roleName"]!="")
{
$query="insert into role(role_id ,roleName) values ('','$_POST[roleName]' ) ";
$result=mysql_query($query);
if($result)
{
$insertData.="Data inserted in Table ";
}
else
{
$insertData.="Data not inserted in Table ";
}
}
else
{
echo "Sorry for Null value";
}
}
if(isset($_POST["search"]))
{
$q="select * from role
where role_id='$_POST[roleID]' ";
$r=mysql_query($q);
while($rows=mysql_fetch_array($r))
{
$roleId=$rows["role_id"];
$roleName=$rows["roleName"];
}
}
echo "<form action='#' method='post'>
role ID: <input type='text' name='roleID' value='$roleId' /><br>
role Name: <input type='text' name='roleName' value='$roleName'/><br>
<input type='submit' value='table Creation' name='Submit' /> ";
echo "<input type='submit' value='Insert' name='Insert' />
<br><input type='submit' value='Search' name='search' />
<font color='red'>$insertData</font></form>";
?>
No comments:
Post a Comment