Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>PHP+MySQL</title>
- </head>
- <body>
- <form action="" method="POST">
- <input type="number" name="id" placeholder="Employee Id"/>
- <input type="text" name="dept" placeholder="Employee Department"/>
- <input type="number" name="salary" placeholder="Employee Salary"/>
- <input type="submit" name="submit" value="Insert"/>
- </form>
- <table border="5" align="center" style="font-size:25px; background:gray;color:white">
- <caption style="color:black">Employee Information Table</caption>
- <thead>
- <td>Employee ID</td>
- <td>Employee Department</td>
- <td>Employee Salary</td>
- </thead>
- <?php
- $host="localhost";
- $user="root";
- $pass="root";
- $db="wps2016f";
- //step 1:MySQL connectivity
- $link=mysqli_connect($host,$user,$pass,$db);
- if(!$link)
- {
- die("Could not connect to MySQL".mysql_error());
- }
- else
- {
- if(isset($_POST['submit']))
- {
- $id=$_POST['id'];
- $dept=$_POST['dept'];
- $salary=$_POST['salary'];
- }
- $iq="INSERT INTO `wps2016f`.`employee` (`emp_id`, `emp_dept`, `emp_salary`) VALUES ('$id', '$dept', '$salary');";
- mysqli_query($link,$iq);
- //$sq="SELECT * from employee where `emp_salary`>2000 and `emp_salary`<6000 order by `emp_dept` ;";
- $sq="SELECT * from employee;";
- //step3: Execute query
- $result=mysqli_query($link,$sq);
- if(!$result)
- {
- die("Could not run the query".mysql_error());
- }
- else
- {
- while($row=mysqli_fetch_row($result))
- {
- echo"<tr>";
- echo"<td>$row[0]</td>";
- echo"<td>$row[1]</td>";
- echo"<td>$row[2]</td>";
- echo"</tr>";
- }
- $query=mysqli_query($link, "SELECT * FROM `employee` WHERE `emp_dept` = 'Business' OR `emp_dept` = 'FAST'");
- }
- }
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement