0

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.

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Bob Arctor
0

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);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.