Hi all,
Been some time since my last post.
I'll get straight to it -

I have actual Id's being passed from the checkbox array to a page where I dump the post variables.

I'm using this to query the db.

$result = mysql_query("SELECT * FROM test WHERE Id='$checkbox[0]';");

while($row = mysql_fetch_array($result))
  {
  echo $row['mobile'] . " " . $row['email'];
  echo "<br />";
  }

Which is fine if I manually create the array
like so

$checkbox[]= array(0=>(1), 1=>(2));

In addition some of the numbers require formatting so -

$mob = $sTestString;
$sPattern = '/\s*/m'; 
$sReplace = '';
$mob = str_replace ('-', '', $mob);
echo $mob . '<br />';
echo preg_replace($sPattern, $sReplace, $mob );

What I want to do is pass the checkbox array to the SELECT directly on form submit.
Then create an array with the mobile numbers and an array with the emails which will need to be processed to a comma sep string. (if more than one email or mobile number).

I need a loop here on the SELECT right and a counter to see how many checkboxes are checked ?
That's where I'm a bit foggy. ;-)
Is there an alternative more efficient way to do this ?

Regards.

Apologies people for some reason I was looking at the wrong loop.
*slapping head*
It should be

foreach ($checkbox as $value){
$result = mysql_query("SELECT * FROM test WHERE Id='$value';");
while($row = mysql_fetch_array($result))
  {
   echo "<br />";
   echo $row['mobile'] . " " . $row['email'];
   echo "<br />";
  }
}
mysql_close($con);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.