Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title> ManageTimeSlot</title>
- <style type="text/css">
- th,td{border:1px solid black; width: 150px;}
- </style>
- </head>
- <body>
- <h2><strong> Current Task:</strong></h2>
- <?php
- //Start or resume a session
- session_start();
- //connect to database
- $db= new mysqli('localhost','root','','assignment1');
- if (mysqli_connect_error())
- {//display the details of any connection errors
- echo 'Error connecting to database:<br/>'.mysqli_connect_error();
- exit;
- }
- if (isset($_POST['task_name']))
- {
- //if ($results-> num_rows > 0)
- // {
- // $error_message='Your data already exist, choose another.';
- //}
- $query= "INSERT INTO tasks VALUE(NULL,'" . $_POST['task_name'] . "')";
- //echo'insert query';
- $result= $db->query($query);
- if ($result)
- {
- echo'<p>User details inserted into database!</p>.';
- }else{
- echo mysqli_error($db);
- }
- }
- $query = "SELECT * FROM volunteer_times AS v JOIN time_slot AS t ON v.time_id = t.time_id
- JOIN tasks AS ta ON v.task_id = ta.task_id'";
- //execute the query
- $results = $db-> query($query);
- // delete user if del_id GET data exists
- if (isset($_GET['del_id']))
- {
- $del_query = 'DELETE FROM tasks WHERE vol_time_id = '.$_GET['del_id'];
- $del_results = $db-> query($del_query);
- }
- //show how many rows the query returned
- //echo '<p>'.$results->num_rows.' users found.</p>';
- //start the table in which our user list will be shown
- echo '<table><tr>';
- echo'<th>Task Name</th><th>Edit</th><th>Delete</th>';
- echo'</tr>';
- //loop through the results and display them
- while ($row=$results-> fetch_assoc())
- {
- $pos_query2='SELECT * FROM tasks WHERE task_name= '.$row['task_name'];
- $pos_results2=$db->query($pos_query2);
- $pos_row2=$pos_results2->fetch_assoc();
- echo '<td>'.$pos_row2['task_name'].'</td>';
- }
- echo'<tr><td><a href="Allocatet.php">Edit</a> </td></tr>';
- echo '<td><a href="ManageTask.php?del_id='.$row['task_name'].'"
- onclick="return confirm(\'Are you sure you want to delete this user?\');"></a></td></tr>';
- ?>
- <h3><strong> Add New Task:</strong></h3>
- <form name="AddTask" method="post" action="ManageTask.php">
- <table style="width: 200px; border: 0px;" cellspacing="1" cellpadding="1">
- <tr>
- <td>Task Name</td>
- <td>
- <input name="task_name" type="text" style="width:200px;" maxlength="20"/>
- </td>
- </tr>
- <td>
- <input type="submit" name="submit" value="Submit" /></td>
- </table>
- <?php echo '<p><a href="logout.php">Log Out</a></p>'; ?>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement