December 7th, 2013, 03:03 PM
Creating an array of checkboxes
I need some help with a problem I am having. I have an internal messaging application. It is only for the members of my website, and does not connect up to external email of any sort. The application works just beautifully. However, the deletion of unwanted emails, only works one at a time. I would like to allow for check box selection of the listed messages, and allow for the group of selected message id's to be deleted from the database all at once.
My message script works just fine, and it displays the topic and sender and date and read attributes. It read the info from the MySql database, displays a line, then reads the next, displays, etc, in the usual normal while loop fashion. I attach a check box at the end of each line. I do not want to disturb the working script. I simply want to add in the ability to assign the message id to the check-box, and create a means to allow for a question to be sure that's what the user intends when they select to "delete" messages, then go ahead and delete the messages, and then come back and display whats in the box again.
What I need, is to understand what I need to assign to the check boxes for the values, and how to transfer this to the script that would go thru the array of check boxes and then I can write the script to move them to the deleted box, which should be a simple task of assigning the attribute of what box it is in in the database.
So the question is, what is the correct method to use to assign the mailid value to the check-boxes at the end of the display line for each message? And how do I transfer this to the new script?
December 7th, 2013, 03:29 PM
December 7th, 2013, 03:36 PM
Unfortunately, this was not any sort of an answer.
Originally Posted by MrFujin
December 7th, 2013, 05:38 PM
Then i am not sure what you are asking for.
Originally Posted by iceregent
Maybe you can explain how you delete messages today? with code?
If you need help on how to delete mulitple message (id), you can look into the IN operator.
to get from the id array to the IN syntax format, i used the [phpnet=join]join[/phpnet] function, but not sure how that will work today, considering protection against SQL Injection.
December 7th, 2013, 08:29 PM
As I tried to explain, I do NOT need help with the code that is already there. Messages are currently deleted from the box it is in, individually, using a delete form. The mailid is part of the record extracted every time a message is read. I thought I did a pretty good job of explaining what I am looking for, but you answered like you had not even read my question/need.
So, as I stated, I attach a check-box after each line of info, and this info comes from a MySql query. Also as I stated, I am looking for the correct way to attach the mailid value to the check-box. And, also as stated, I need to understand the correct method to send this array of check-boxes to the next script that will process the multi-delete function based upon the check-boxes that are checked. Since the only check boxes that will show up, are the ones that are checked, this is easy. I just need to know the correct method to attach the mailid value tot he check-box, and then the correct method to pass this array of check-boxes to the processing script.
December 7th, 2013, 11:15 PM
To assign a value from the database to the check-box inside a loop, I would have something like this:
where row['mailid'] is the mail id from the current row from the database.
<input value="'.row['mailid'].'" name="invite" type="checkbox">
I am not sure what you mean with
If you have a the checkboxes and delete button inside a form, then the delete button should be defined as a submit type whereby the checked value should be sent to the script specified in the form action tag.
If you want to have the values avaible through several (script) pages, you should take a look into the [phpnet=SESSION]SESSION[/phpnet] variable.
Hope this is what you are looking for.
December 8th, 2013, 12:12 AM
Ok, I figured it out on my own, this thread is resolved. Thank you for your help.
Comments on this post