Jump to content

looping with curl


rbarnett

Recommended Posts

I'm trying to grab some data off of a list of webpages and display it to the page.  The list of urls are from a mysql table and I then use the curl function to grab the data.  The only problem is that I only get the first row.

 

Can anyone please tell me what I am doing wrong.  When I echo $row['website'] without the curl section I get my full listing.

 

Here is the code:

$query = "select accountname, website from vtiger_account where website <> ''";
$result = mysql_query($query);

echo '<table border="1">
<th>iPass Site</th><th>Version</th>';
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
			$url = $row['website'];
			echo '<tr><td>'.$url.'</td>';
			//echo $url . '<br />';
			$ch = curl_init();
							curl_setopt($ch, CURLOPT_URL, $url);
							curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
							$data = curl_exec ($ch);
							curl_close ($ch);

							$length=strpos($data,"Version: ");
							$result=substr($data,$length +9,32);

							if (preg_match("/Version:/", $data))
							{
								echo '<td>'.$result . '</td></tr>';
							}
							else
							{
								echo '<td>No version found</td></tr>';			
							}					
}

echo '</table>';

Link to comment
https://forums.phpfreaks.com/topic/127587-looping-with-curl/
Share on other sites

sorry your not meant to echo it. the number is the value of the old error reporting value.

but you get no new errors?

try adding this above the loop

echo mysql_num_rows($result);

should tell you how many results you are getting back

 

Scott.

Link to comment
https://forums.phpfreaks.com/topic/127587-looping-with-curl/#findComment-660189
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.