Hi all:

I'm trying to pull from a table all values of a specific row (accountids) and would like to iterate through each query result while perform a specified task with each value.

Example: The following q--

$get_acctids="select accountid from company_info";
$result = mysql_query($get_acctids) or die(mysql_error());
while($row = mysql_fetch_array($result)){
  $id_num= $row['accountid'];

Outputs the following ids:


Now, I would like to iterate through each id while executing another script (at a different location) with each id as a variable being passed to that script.

I would appreciate some thoughts on this!


Recommended Answers

All 5 Replies

Different location on another server? Have a look at curl.

I appreciate the reply, Pritaeas! No, everything is on the same server. I'm simply trying to call another file while passing each variable to the secondary script.

Another interested thought is that each call of the script (with each id) would be done at a time interval (maybe every 1 minute until the iteration is completed. This may be quite a radical idea, but I hope it is possible!

Sounds like a cron job. Make a script that is scheduled to run every minute, it will get the first unhandled id from the database, process it, and mark it ready.

Cron Job (CJ) is percisely what I'm doing with the initial script; my challenge is to iterate throught the result of the query while executing a secondary script (in a separate file) which requires an id from the first script. Essentitally, if the first script returns and is iterating through 5 ids, then, the secondary script will need to be executed 5 times. This is the difficulty at hand.

If the script is a ready one, curl/file_get_contents is still an option. Also, a simple include can work too. It depends a little on what the second script does, and whether or not you have to wait for a response.

Be a part of the DaniWeb community

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