Search the Community
Showing results for tags 'php mysql delete multiple row'.
-
Hi guys I'm trying to a way of deleting multiple user inbox messages with checkboxes, this is what i've got so far. <?php include 'gradnetconn.php'; require_once ('webpage.class.php'); session_start(); $messageTo = $_SESSION['userID']; if (!(isset($_SESSION['userID']) && $_SESSION['userID'] != '')) { echo "Log in to send a message" ; header ("Location: login.php"); } else { echo "You aree logged in, please feel free to delete a message "; } $sql="SELECT * FROM gn_messages WHERE messageTo = $messageTo AND messageDeleted = '0' ORDER BY messageDate DESC"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete A Message</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Message ID</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>From</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Subject</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Date</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['messageID']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['messageID']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['messageFrom']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['messageSubject']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['messageDate']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php // Check if delete button active if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM gn_messages WHERE messageID='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> It says undefined variable delete. Shouldn't this correspond to the ID of the delete button? Notice: Undefined variable: delete (line 70) Thanks