JLitkie Posted May 30, 2010 Share Posted May 30, 2010 I am writing a code that displays the messages from a database and then has the option to delete a message. Everything is working great except that I can only delete the first message in the list of messages every time. Cant seem to figure this one guys.. any help would be appreciated. Here is the code: <font size="6" face="Arial"><b><center>Administration Area</center></b></font><br><br> <!-- Start of FORM --> <form method="POST" action="messages.php"> <center> <table border="0" width="90%"> <tr><!-- Row 1 --> <td align="left"><input type="submit" value="Delete"></td><!-- Col 1 --> <td></td><!-- Col 2 --> </tr> </table> </center> <center><table border="1" width="90%" style="border-bottom:none;border-left:none;border-right:none;border-top:none;"> <tr> <td valign='top' align="center" style="border-bottom:none;border-left:none;border-right:none;border-top:none;">Check</td><!-- Col 1 --> <td valign='top' style="border-bottom:none;border-left:none;border-right:none;border-top:none;">Date</td><!-- Col 1 --> <td style="border-bottom:none;border-left:none;border-right:none;border-top:none;"> Subject </td></tr><!-- Col 1 --> <?php include('database.php'); $cxn = mysqli_connect($host,$user,$password,$dbname) or die ("Couldn't connect to server"); $sql = "SELECT * FROM messages WHERE File='Inbox'"; $result = mysqli_query($cxn,$sql); while($row = mysqli_fetch_row($result)) { echo "<tr> <td valign='bottom' width='10%' align='center'><input type='checkbox' name='Delete' value='$row[0]'></td>"; echo "</form><form method='POST' action='messages2.php'>"; echo "<td valign='bottom' width='15%'>$row[4]</td><!-- Col 1 --> <td valign='bottom' width='60%'> <input type='hidden' name='ID' value=".$row[0]."> <input type=submit value='".$row[2]."' style='background-color:transparent;border:none;font-family:arial;font-size:inherit;font-weight:bold;color:#FF0000;'> </td></tr><!-- Col 1 --> "; echo "</form>"; } print "</table></center>"; ?> </form> Link to comment https://forums.phpfreaks.com/topic/203324-message-coding-problem/ Share on other sites More sharing options...
ghostcoder Posted May 30, 2010 Share Posted May 30, 2010 I don't see any delete query. Maybe you could post the code that handles the POST data and the deleting of the message. Link to comment https://forums.phpfreaks.com/topic/203324-message-coding-problem/#findComment-1065254 Share on other sites More sharing options...
JLitkie Posted May 30, 2010 Author Share Posted May 30, 2010 Sorry about that, i thought I had put the full coding in but only got a part of it. The full page coding is included. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <style type="text/css"> a:link {text-decoration: none;} a:visited {text-decoration: none;} </style> <?php IF((isset($_POST['Delete'])) == TRUE) { $Delete = $_POST['Delete']; } ELSE { $Delete = ""; } include('database.php'); $cxn = mysqli_connect($host,$user,$password,$dbname) or die ("Couldn't connect to server"); $sql = "DELETE FROM messages WHERE ID='$Delete'"; $result = mysqli_query($cxn,$sql) or die("Couldn't execute query: ".mysqli_error($cxn)); ?> </head> <body bgcolor="#000000" text="#FFFFFF" link="#FF0000" vlink="#FF0000" alink="#FFFFFF"> <div style="position:absolute;left:2%;top:5%;height:79%;width:16%;"> <center> <font size="5" face="Arial"><b><u>Site Guide</u></b></font><br><br> <font size="4" face="Arial"><a href="indexmain.php">Home</a></font><br><br> <font size="4" face="Arial"><a href="messages.php">Messages</a></font><br><br> <font size="4" face="Arial"><a href="orders.php">Order Requests</a></font><br><br> <font size="4" face="Arial"><a href="girls.php">Edit The Girls</a></font><br><br> <font size="4" face="Arial"><a href="guys.php">Edit The Guys</a></font><br><br> <font size="4" face="Arial"><a href="puppies.php">Edit The Puppies</a></font><br><br> <font size="4" face="Arial"><a href="about.php">Edit Our Story</a></font><br><br> <font size="4" face="Arial"><a href="photos.php">Edit Photos</a></font><br><br> </center> </div> <div style="position:absolute;left:18%;top:5%;height:45%;width:26%;"> <img src="../Graphics/bmm_Logo.jpg" width="100%" height="99%" alt="" border="1" align="" style="border-color:#FFFFFF;"> </div> <div style="position:absolute;left:44%;top:5%;height:79%;width:55%;max-width:55%;"> <font size="6" face="Arial"><b><center>Administration Area</center></b></font><br><br> <!-- Start of FORM --> <form method="POST" action="messages.php"> <center> <table border="0" width="90%"> <tr><!-- Row 1 --> <td align="left"><input type="submit" value="Delete"></td><!-- Col 1 --> <td></td><!-- Col 2 --> </tr> </table> </center> <center><table border="1" width="90%" style="border-bottom:none;border-left:none;border-right:none;border-top:none;"> <tr> <td valign='top' align="center" style="border-bottom:none;border-left:none;border-right:none;border-top:none;">Check</td><!-- Col 1 --> <td valign='top' style="border-bottom:none;border-left:none;border-right:none;border-top:none;">Date</td><!-- Col 1 --> <td style="border-bottom:none;border-left:none;border-right:none;border-top:none;"> Subject </td></tr><!-- Col 1 --> <?php include('database.php'); $cxn = mysqli_connect($host,$user,$password,$dbname) or die ("Couldn't connect to server"); $sql = "SELECT * FROM messages WHERE File='Inbox'"; $result = mysqli_query($cxn,$sql); while($row = mysqli_fetch_row($result)) { echo "<tr> <td valign='bottom' width='10%' align='center'><input type='checkbox' name='Delete' value='$row[0]'></td>"; echo "</form><form method='POST' action='messages2.php'>"; echo "<td valign='bottom' width='15%'>$row[4]</td><!-- Col 1 --> <td valign='bottom' width='60%'> <input type='hidden' name='ID' value=".$row[0]."> <input type=submit value='".$row[2]."' style='background-color:transparent;border:none;font-family:arial;font-size:inherit;font-weight:bold;color:#FF0000;'> </td></tr><!-- Col 1 --> "; echo "</form>"; } print "</table></center>"; ?> </form> <!-- End of FORM --> </div> <div style="position:absolute;left:18%;top:51%;height:33%;width:26%;"> </div> <div style="position:absolute;left:2%;top:85%;height:13%;width:98%;"> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/203324-message-coding-problem/#findComment-1065283 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.