<form name='search' method='get' action=''>
Insert the firstname
<input type='text' name='txtname'>
<input type='submit' value='search name'>
</form>
<?php
//database connect
$db=mysqli_connect("localhost","root","","mycompanyhr");
//checking database connection
if ($db==false) {
echo "Connect failed: ". mysqli_connect_error($db);
exit();
}
else {
echo "Connection successful";
}
$n=$_GET['txtname'];
$sql="select EMPNO, FIRSTNAME, LASTNAME, WORKDEPT,
PHONENO
from employee
where FIRSTNAME like '%$n%' ";
$rs=mysqli_query($db,$sql);
if($rs==false){
echo ("Query cannot be executed!<br>");
echo ("SQL Error : ".mysqli_error($db));
}
else{
echo "<table border=1>";
echo "<tr>";
echo "<td></td>";
echo "<td>Employee no</td>";
echo "<td>First name</td>";
echo "<td>Last name</td>";
echo "<td>Department</td>";
echo "<td>Phone ext</td>";
echo "</tr>";
while($rekod=mysqli_fetch_array($rs)){
echo "<tr>";
$empno=$rekod['EMPNO'];
echo "<td> <a href='delete.php?id=$empno'>
delete </a> </td>";
echo "<td>".$empno."</td>";
echo "<td>".$rekod['FIRSTNAME']."</td>";
echo "<td>".$rekod['LASTNAME']."</td>";
echo "<td>".$rekod['WORKDEPT']."</td>";
echo "<td>".$rekod['PHONENO']."</td>";
echo "</tr>";
}//end while
}//end null
echo "</table>";
?>
Scenario You are given a task to develop a simple web database application for a movies rental shop. The system will store the information of all the movies available in the shop. Below are the information needed for the database. Database server information : server address= localhost , username= root , no password Database name: MOVIEDB This is the database source Table name : Movies Fields in table Movies : MovieID , MovieTitle , Category , Director , YearProduced , RentalPrice . Tasks 1. Create the database and table as stated above (using MySQL through phpMyAdmin). Populate the database by entering at least 5 movie titles. 2. Develop the web pages (combination of HTML and PHP scripts) to search and display the movies information by MovieTitle and YearProduced . 3. Develop a HTML form for the user to insert a new record of a new movie. Prepare the input for Category and YearProduced using the select option list. The categories are fiction , horror , comedy , ...
Comments
Post a Comment