Ok, so let’s say I have a list of users in a database. I want to get that list out on the screen and allow someone to be able to use checkboxes to do something with each of those users. In this example we’re going to say we are deleting any users that have been checked. If you are not already familiar with building dynamic output from mysql then I suggest you first read over Web Dev > Populate PHP/HTML table from MySQL database
First we’ll build our form to show our users, in this example I’m actually building my list of users from a query to a mail server which gets returned to me first as a string. I need to change this into an array so I’m going to use explode(). I’ll go through this all step by step so it’s easy to follow along and you can skip whatever parts you feel you are already familiar with.
So lets say the mail server returns this string to me of users:
$members_string = 'Bruce Chuck Jackie Jet'; echo "Members string is '$members_string'";
Which gives us an output of
Members string is 'Bruce Chuck Jackie Jet'
Since I want to loop through each of these members I need to first create an array that I can loop through, this is where explode() comes in.
// Members are separated by spaces, so explode on spaces $members = explode(' ',$members_string);