2

I have an Sql database setup where the e-mail address is compared. If the e-mail address matches then I pull out the Company name, and Name associated with that e-maill address.

Ex.

example@example.com, John Smith, Quick Company

The following is the rest of the code which will then goto a .php script inside the directories of that Company -> Name

$base_path = '/var/www/vhosts/default/htdocs/Members/';

$path = $base_path . trim($row['company']) . '/Users/' . trim($row['name']) .     '/Upload/';

$zip_processing_file = $path . 'zip.php';

require_once "$zip_processing_file";

My problem is this. If I have 2 emails sitting in my inbox, one from test@example.com and another from test2@example.com.

Whichever email is the newest, that is the directory that this script will take me too. Is there a way to get both .php scripts for test & test2 processed?

Thanks!

Shane Stillwell
  • 3,198
  • 5
  • 31
  • 53
John
  • 131
  • 1
  • 1
  • 3
  • I'd be curious to see how you're getting that data out of the database. It might just be a case of looping over your result set and calling `require_once` on a path you've constructed from each row. It kinda sounds like you're only grabbing one row from your result set and just using that. – Lucas May 05 '11 at 06:46
  • somehow the question is not clear to answer. Can you give the code – AjayR May 09 '11 at 04:07
  • Your problem is not very clear. Do both test@example.com and test2@example.com belong to the same company? Is there a different zip processing file for every person? if yes - why? – boug May 10 '11 at 12:20

1 Answers1

0

you should use a foreach loop, for every company. I am assuming you have the company names in an array.

Try something like this:

foreach ($rows as $row)
{
    $path = $base_path . trim($row['company']) . '/Users/' . trim($row['name']) .     '/Upload/';
    $zip_processing_file = $path . 'zip.php';
    require_once "$zip_processing_file";
}

Also, make sure you have unique companies in your array. If not, require_once might trow an error. You might use require() or include() if your not sure if there is a duplicate. But better to prevent ofcourse

Rene Pot
  • 24,681
  • 7
  • 68
  • 92