#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2010
    Posts
    30
    Rep Power
    0

    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?
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,662
    Rep Power
    1945
    You do know html has syntax to create checkbox?.

    Example to use checkbox
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2010
    Posts
    30
    Rep Power
    0
    Originally Posted by MrFujin
    You do know html has syntax to create checkbox?.

    Example to use checkbox
    Unfortunately, this was not any sort of an answer.
  6. #4
  7. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,662
    Rep Power
    1945
    Originally Posted by iceregent
    Unfortunately, this was not any sort of an answer.
    Then i am not sure what you are asking for.

    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.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2010
    Posts
    30
    Rep Power
    0
    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.
  10. #6
  11. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,662
    Rep Power
    1945
    I am looking for the correct way to attach the mailid value to the check-box
    To assign a value from the database to the check-box inside a loop, I would have something like this:
    Code:
    <input value="'.row['mailid'].'"  name="invite[]" type="checkbox">
    where row['mailid'] is the mail id from the current row from the database.

    I am not sure what you mean with

    ... to the next script that will process the multi-delete ...
    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.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2010
    Posts
    30
    Rep Power
    0

    resolved


    Ok, I figured it out on my own, this thread is resolved. Thank you for your help.

    Comments on this post

    • Jacques1 disagrees : Please don't close your threads. Often times, people have additional comments. You should also post the solution so that other users can benefit from it. A thread ending with "Fixed it. Bye." isn't very helpful in a forum.
    • BarryG disagrees : It's OK Jacques. He figured out that you name the checkboxes with name[], and php submits the values as an array in the POST or GET

IMN logo majestic logo threadwatch logo seochat tools logo