Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title> ManageTimeSlot</title>
  5. <style type="text/css">
  6. th,td{border:1px solid black; width: 150px;}
  7. </style>
  8. </head>
  9.  
  10. <body>
  11. <h2><strong> Current Task:</strong></h2>
  12.  
  13. <?php
  14. //Start or resume a session
  15. session_start();
  16.  
  17. //connect to database
  18.  
  19. $db= new mysqli('localhost','root','','assignment1');
  20. if (mysqli_connect_error())
  21. {//display the details of any connection errors
  22. echo 'Error connecting to database:<br/>'.mysqli_connect_error();
  23. exit;
  24. }
  25. if (isset($_POST['task_name']))
  26. {
  27.  
  28. //if ($results-> num_rows > 0)
  29. // {
  30. // $error_message='Your data already exist, choose another.';
  31.  
  32. //}
  33.  
  34. $query= "INSERT INTO tasks VALUE(NULL,'" . $_POST['task_name'] . "')";
  35. //echo'insert query';
  36. $result= $db->query($query);
  37.  
  38. if ($result)
  39. {
  40. echo'<p>User details inserted into database!</p>.';
  41. }else{
  42. echo mysqli_error($db);
  43. }
  44. }
  45.  
  46. $query = "SELECT * FROM volunteer_times AS v JOIN time_slot AS t ON v.time_id = t.time_id
  47. JOIN tasks AS ta ON v.task_id = ta.task_id'";
  48.  
  49. //execute the query
  50. $results = $db-> query($query);
  51. // delete user if del_id GET data exists
  52. if (isset($_GET['del_id']))
  53. {
  54. $del_query = 'DELETE FROM tasks WHERE vol_time_id = '.$_GET['del_id'];
  55. $del_results = $db-> query($del_query);
  56. }
  57. //show how many rows the query returned
  58. //echo '<p>'.$results->num_rows.' users found.</p>';
  59.  
  60. //start the table in which our user list will be shown
  61. echo '<table><tr>';
  62. echo'<th>Task Name</th><th>Edit</th><th>Delete</th>';
  63. echo'</tr>';
  64. //loop through the results and display them
  65. while ($row=$results-> fetch_assoc())
  66. {
  67. $pos_query2='SELECT * FROM tasks WHERE task_name= '.$row['task_name'];
  68. $pos_results2=$db->query($pos_query2);
  69. $pos_row2=$pos_results2->fetch_assoc();
  70. echo '<td>'.$pos_row2['task_name'].'</td>';
  71. }
  72. echo'<tr><td><a href="Allocatet.php">Edit</a> </td></tr>';
  73. echo '<td><a href="ManageTask.php?del_id='.$row['task_name'].'"
  74. onclick="return confirm(\'Are you sure you want to delete this user?\');"></a></td></tr>';
  75. ?>
  76. <h3><strong> Add New Task:</strong></h3>
  77. <form name="AddTask" method="post" action="ManageTask.php">
  78. <table style="width: 200px; border: 0px;" cellspacing="1" cellpadding="1">
  79. <tr>
  80. <td>Task Name</td>
  81. <td>
  82. <input name="task_name" type="text" style="width:200px;" maxlength="20"/>
  83. </td>
  84. </tr>
  85.  
  86. <td>
  87. <input type="submit" name="submit" value="Submit" /></td>
  88.  
  89. </table>
  90. <?php echo '<p><a href="logout.php">Log Out</a></p>'; ?>
  91. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement