Minase Posted June 23, 2008 Share Posted June 23, 2008 hy there i want to make a function that show the messages that are holded into an DB,everything nice,but when i try to delete the message,it delete just one (the last record from DB) near messages i do have a checkbox and checkbox have the name of message ID (uniq) how can i make to delete everything that i want,it seem that it doesnt respect IF statement. look at my function function ShowMessages() { global $db; $msgcount1 = "SELECT * FROM `" . DBPREFIX . "users_messages` WHERE `ReciverID` = " . $db->qstr ( $_SESSION['user_id'] ); $msgcount = $db->RecordCount($msgcount1); if ($msgcount == 0) { echo '<center>No new message</center>'; } else if ($msgcount > 0) { echo ' </td></tr> <tr><td align="center" class="tdn" colspan=3><select class=input name="wn" size=1><option value="b">tagged messages<option value="a">all messages<option value="c">untagged messages</select> <select name="to" size=1 class=input> <option value="l">delete</select> <input type=submit name="do" class=input value="Go!"></th></tr> <input type=hidden name="o" value="0">'; $query = "SELECT * FROM `" . DBPREFIX . "users_messages` WHERE `ReciverID` = " . $db->qstr ( $_SESSION['user_id'] ) . " ORDER BY SendTime DESC LIMIT 0,50"; $query1 = mysql_query($query); $message = $db->getRow ( $query ); while ($mess = mysql_fetch_array($query1)) { if ($message->MessageType == 1) { $sendername1 = "SELECT Username FROM `" . DBPREFIX . "users` WHERE `ID` = " . $db->qstr ( $mess['SenderID'] ); $sendername = $db->getRow ($sendername1); $suid2 = $mess['ID']; echo ' <tr> <td class="tdn" valign="top"> <input type=checkbox name="',$mess['ID'],'" value="y"> </td>'; echo ' <td width="30%" class="tdn" valign="top">'.date("D, d.m.Y - H:i:s",$mess['SendTime']).'</td>'; echo' <td class="tdn"><table width="100%"> <tr> <td>message <a href="player.php?p='.$mess['SenderID'].'">'.$sendername->Username.'</a> | Subject:'.$mess['Subject'].'</td> <td align="right"><a class="copyright" href="msgbad.php?mn=9240519">(report)</a></td></tr> <tr><td colspan=2><textarea cols=55 rows=4 class=input>'.$mess['Message'].'</textarea></td></tr><tr><td><a href="msgnew.php?st='.$sendername->Username.'">answer</a></td></tr></table><br></th></tr> '; } } } if($_POST['do'] == "Go!") { if($_POST['wn'] == "b") { if($_POST['to'] == "l") { mysql_query("DELETE FROM `" . DBPREFIX . "users_messages` WHERE ReciverID = " . $_SESSION['user_id'] . " AND ID = " . $suid2 . "") or die(mysql_error()); } } else if ($_POST['wn'] == "a") { mysql_query("DELETE FROM `" . DBPREFIX . "users_messages` WHERE ReciverID =" . $_SESSION['user_id'] . "") or die(mysql_error()); } else if ($_POST['wn'] == "c") { mysql_query("DELETE FROM`" . DBPREFIX . "users_messages`WHERE ReciverID = " . $_SESSION['user_id'] . " AND ID != " . $suid2 . "") or die(mysql_error()); } } echo ' <tr><td align="center" class="tdn" colspan=3><select class=input name="wn" size=1><option value="b">tagged messages<option value="a">all messages<option value="c">untagged messages</select> <select name="to" size=1 class=input> <option value="l">delete</select> <input type=submit name="do" class=input value="Go!"></th></tr> '; } i did try various things on it,but it result in same thing ??? anyone have a clue what can be? thank you very much Link to comment https://forums.phpfreaks.com/topic/111455-php-and-mysql-delete-question/ Share on other sites More sharing options...
Minase Posted June 23, 2008 Author Share Posted June 23, 2008 anyone please? Link to comment https://forums.phpfreaks.com/topic/111455-php-and-mysql-delete-question/#findComment-572543 Share on other sites More sharing options...
.josh Posted June 23, 2008 Share Posted June 23, 2008 well i can't be sure since you didn't bother to use indentation, but it looks like your delete query isn't in any kind of loop. Link to comment https://forums.phpfreaks.com/topic/111455-php-and-mysql-delete-question/#findComment-572547 Share on other sites More sharing options...
ratcateme Posted June 23, 2008 Share Posted June 23, 2008 sorry silly question igonre Link to comment https://forums.phpfreaks.com/topic/111455-php-and-mysql-delete-question/#findComment-572555 Share on other sites More sharing options...
Minase Posted June 23, 2008 Author Share Posted June 23, 2008 it seem that i have a very messy code. can anyone please give a basic code that select something from DB - > echo it - >+ checkboxes with 3 delete option 1 delete checked messages 2 delete all 3 delete unchecked just a basic script please.i really dont know how i can do this one ??? thanks again for your time Link to comment https://forums.phpfreaks.com/topic/111455-php-and-mysql-delete-question/#findComment-572675 Share on other sites More sharing options...
.josh Posted June 23, 2008 Share Posted June 23, 2008 If you want someone to write a script for you post asking for it in the freelance section, along with how much you're willing to pay. Yes, pay. Link to comment https://forums.phpfreaks.com/topic/111455-php-and-mysql-delete-question/#findComment-572677 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.