How can I pull multiple rows from a MySQL table and use all of them automatically for the same thing

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2010-04-21T17:13:49Z Indexed on 2010/04/21 17:23 UTC
Read the original article Hit count: 154

Filed under:
|
|
|
|

Basically, I have multiple URL's stored in a MySQL table. I want to pull those URLs from the table and have cURL connect to all of them. Currently I've been storing the URL's in the local script, but I've added a new page that I can add and remove them from the database, and I'd like the page to reflect it appropriately.

Here is what I currently have:

  $sites[0]['url'] = "http://example0.com ";
  $sites[1]['url'] = "http://example1.com";
  $sites[2]['url'] = "http://example2.com";
  $sites[3]['url'] = "http://example3.com";

  foreach($sites as $s) 
  {
   // Now for some cURL to run it.
   $ch = curl_init($s['url']); //load the urls and send GET data
   curl_setopt($ch, CURLOPT_TIMEOUT, 2); //No need to wait for it to load. Execute it and go.
   curl_exec($ch); //Execute
   curl_close($ch); //Close it off 
  }

Now I assume it can't be too amazingly difficult to do, I just don't know how. So if you could point me in the right direction, I'd be grateful. But if you supply me with some code, please comment it appropriately so that I can understand what each line is doing.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql