I've got a little script just to work out how to do something for a larger project.
At the moment, all you do is enter in a list of names
Ben; John; Frank; James
or whatever, and it displays their emails from a database.
This is the code that I'm using...
($names is just a text variable entered by the user in a form)
if ($submit) {
include "../cgi-bin/connect.inc";
$split_words = split(";", $words);
$arraysize = count($split_words);
echo "Array Size: $arraysize<br>";
for ($i=0;$i<$arraysize;$i++) {
$mailing_list=mysql_query("SELECT email FROM table WHERE name='$split_words[$i]'",$db);
while ($list=mysql_fetch_array($mailing_list)) {
$email = $list["showemail"];
}
echo "Email: $email";
}
}
however, this only works if you put in names like
Ben;John;Frank;James
I need it to allow other things, like
Ben, John...
Ben; John..
Ben,John..
so I tried adding in
$split_words = split(",", $words);
$split_words = split("; ", $words);
$split_words = split(", ", $words);
but it doesn't work at all now because it doesn't know what to do with $words, which option to choose.
I imagine this is a common problem, but I have no idea what to look for or where to find it, so if someone has a solution, or a way of finding one I'd really appreciate it
Thanks for any help