Monshery Posted November 1, 2006 Share Posted November 1, 2006 Well basicaly i am trying to make a Admin side of my data base show thats means that php basicaly will print all the lines 1 by 1 in dec order and show them what i am trying to do and cant figure out whats not working is .. i added a check box in every fatch array .... and i am trying to make an array with this check box so i could delete several massages at once if i want here here is the exact code :[code] <?php// well basicaly if i make this to work i will know how to delete enough that i will know that i can send me //the array but somewhy it wont send me. foreach ($_POST["checkbox"] as $key=>$val) echo "key:$key value:$val<BR>\n";?> <table width="444" border="0"> <tr> <td height="23"><div align="left"><span class="style3">my admin</span></div><div align="right"><span class="style5">הודעות מעודכנות להיום</span></div></td> </tr> <tr> <td width="438" height="33" bgcolor="#006699"> <form action="Admin.php" method="POST"> <table width="437" border="0" style="border-width: 0px"> <tr> <td bgcolor="#FFFFFF" class="style1" style="border-style: none; border-width: medium"><!-- php database --><?php $post_LINK=mysql_connect('xxxxxxxxx','xxxxxxxx','xxxxxxx') or die("Connection fail"); mysql_select_db('xxxxxxxxx',$post_LINK); $MASSAGES_links = mysql_query("SELECT * FROM xxxxxxx ORDER BY id DESC",$post_LINK); while($MASSEGES=mysql_fetch_array($MASSAGES_links)) { ?> <div align="right"></div> <div align="right"> <table width="432" height="77" border="0" bgcolor="#FFFFFF"> <tr> <td width="167" height="23"> <div align="left"> <input type="checkbox" name="checked[<?php print $MASSEGES['id']; ?>]" value="<?php print $MASSEGES['id'];?>"> למחיקת הודעה סמן </div></td> <td width="167"><div align="right"><?php echo $MASSEGES['name'];?></div></td> <td width="30"><div align="right">:שם </div></td> <td width="52"><div align="right"><?php echo $MASSEGES['id'];?> </span></div></td> </tr> <tr> <td height="23" colspan="3"><div align="right"><?php echo $MASSEGES['email'];?></div> <div align="right"></div></td> <td height="23"><div align="right">: נושא</div></td> </tr> <tr> <td height="23" colspan="4"><p align="right">:הודעה</p> <p align="right"><?php echo $MASSEGES['massage'];?></p> <p align="right">----------------------------------------------------------------------------------- </p></td> </tr> </table> <?php } ?> </div></td> </tr> </table> <input name="deletem" type="submit" id="deletem" value="מחק את ההודעות"> </form> </td> </tr></table>[/code]Thanks in advance sorry for so long code didnt know how to sammorzing it . Quote Link to comment https://forums.phpfreaks.com/topic/25786-not-very-simple-question-but-here-its-is-its-about-checkboxs-formdelete-d/ Share on other sites More sharing options...
HuggieBear Posted November 1, 2006 Share Posted November 1, 2006 Don't forget to remove your database connection info when posting.I'd suggest calling each of the checkboxes the same thing, something like [color=green]todelete[][/color] but with the value of [code=php:0]$MASSEGES['id'][/code] this way you'll end up with an array called [color=green]$todelete[/color] in php and you can use it something like this:[code]<?php$delete = implode(",", $todelete); // This creates a string of id's e.g. "1,4,8,"$limit = count($todelete); // set a limit as a safety precaution$sql = "DELETE FROM tablename WHERE id IN ($delete) LIMIT $limit";$result = mysql_query($sql);if ($result){ echo "The following ID's were successfully deleted: $delete\n";}else { echo "There was an error deleting rows from the database\n";}?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/25786-not-very-simple-question-but-here-its-is-its-about-checkboxs-formdelete-d/#findComment-117739 Share on other sites More sharing options...
Monshery Posted November 1, 2006 Author Share Posted November 1, 2006 my bad your right just fixed it . anyways you know how i solve it ? Quote Link to comment https://forums.phpfreaks.com/topic/25786-not-very-simple-question-but-here-its-is-its-about-checkboxs-formdelete-d/#findComment-117742 Share on other sites More sharing options...
Monshery Posted November 1, 2006 Author Share Posted November 1, 2006 bump - any chance someone helping me here ? Quote Link to comment https://forums.phpfreaks.com/topic/25786-not-very-simple-question-but-here-its-is-its-about-checkboxs-formdelete-d/#findComment-117917 Share on other sites More sharing options...
HuggieBear Posted November 1, 2006 Share Posted November 1, 2006 Did you even look at my edit?Huggie Quote Link to comment https://forums.phpfreaks.com/topic/25786-not-very-simple-question-but-here-its-is-its-about-checkboxs-formdelete-d/#findComment-117936 Share on other sites More sharing options...
Monshery Posted November 1, 2006 Author Share Posted November 1, 2006 i did looked but matey .. id didnt worked iether way . i tryed it again now that i am a bit more awake and still nothing Quote Link to comment https://forums.phpfreaks.com/topic/25786-not-very-simple-question-but-here-its-is-its-about-checkboxs-formdelete-d/#findComment-117950 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.