php - Being able to delete a certain result from an SQL while loop -
i have looked around answer cannot seem find one.
i able delete specific query database.
how able remove specific 1 form , post sql statement delete?
here current select statement.
<? if (isset($_post['submit'])) { echo "hello!"; $selectoption = $_post['info']; $query = "select * `requests` order $selectoption"; echo $query; $result = $db->query($query); if ($result == false) { die ("could not execute statement $query<br />"); } else echo "<form action='' method='post'>"; echo "<table>"; while($row=$result->fetchrow()){ if ($row['status'] == 0) { $type="rejected"; } else if ($row['status'] == 1){ $type="pending"; } else if ($row['status'] == 2){ $type="accepted"; } echo "<tr id=".$type."><td>" . $row['requestid'] . "</td>"; echo "<td>" . $row['booking_type'] . "</td>"; echo "<td>" . $row['userid'] . "</td>"; echo "<td>" . $row['moduleid'] . "</td>"; echo "<td>" . $row['no_rooms'] . "</td>"; echo "<td>" . $row['park'] . "</td>"; echo "<td>" . $row['semester'] . "</td>"; echo "<td>" . $row['day'] . "</td>"; echo "<td>" . $row['start_time'] . "</td>"; echo "<td>" . $row['end_time'] . "</td>"; echo "<td>" . $row['length'] . "</td>"; echo "<td>" . $row['students'] . "</td>"; echo "<td>" . $row['priority'] . "</td>"; echo "<td>" . $row['comments'] . "</td>"; echo "<td>" . $row['status'] . "</td>"; // <td class="'.(($row['status'] == 2) ? 'status-rejected' : 'status-accepted'). '">'.$row['status'].'</td>'; echo "<td>".$stats."</td>";*/ echo "<td>" . $row['round'] . "</td>"; echo "<td>" . $row['date_submitted'] . "</td>"; } echo "</tr>"; echo "</table>"; echo "</form>"; } echo "</tr>"; echo "</table>";
i don't understand trying delete.
if want delete data / row in database, need use delete statement explained here: http://www.w3schools.com/sql/sql_delete.asp
i guess statement this:
delete requests requestid=$row['requestid'];
$row['requestid'] actual unique key identifier data row delete.
edit: create button / link exact page data (yourpage.php?deleteid=1) pass id of data delete database.
keep in mind using paratemers isn't best way this. should rather use form , post regarding id.
Comments
Post a Comment