php search functions

June 25, 2010 at 11:57:54
Specs: Windows XP
Hey, I'm looking for the right functions to have
PHP search for the recipient of the email and
search a csv or sql to print values corresponding
to that email addy within the emailer.
So in other words,
I'd like the email to know who its being sent to and address them (within the body) with the proper name stored in a CSV (or what ever is easier).

See More: php search functions

Report •

June 27, 2010 at 13:17:49
I'm not sure what you're asking about, but it *seems* like you're wanting to post details of a target email address? If so, then an sql *might* look something like.

$res = mysql_query("select * from tbl_name where email='" . $desired_email_address . "' limit 1;") or die(mysql_error());

if(mysql_num_rows($res) == 1) {
   while($row = mysql_fetch_assoc($res)) {
      foreach($row as $key => $val) {
         // do something with $val

With csv, you'd need to open the file and parse each line

$fh = @fopen("csv_file_name", "r");
if($fh) {
   if(flock($fh, LOCK_EX)) {
      while(!feof($fh)) {
         $line = fgets($fh);
         if(strstr($line, $target_email_address) !== FALSE) {
            $data = split(",", $line); // $data *is* an array
      flock($fh, LOCK_UN);


Perhaps something to that effect; without knowing the structure of your data or really what you want, the above it just a guess.


Report •
Related Solutions

Ask Question