- I have gone to the db and created an array of url's.
- Then I go through the array and use xpath to tell me how many links there are per url.
- This is where my head hurts.
I have a count for each url of the no of objects in each url. So I'm now trying to collect each of the nodevalues from part 2.
I'm obviously doing something wrong but need some guidence please
$items = array(); $query = "SELECT * FROM `urls`"; if( $result = mysqli_query($sql,$query)); { // Return the number of rows in result set $rowcount=mysqli_num_rows($result); while ($row = $result->fetch_assoc()) { $items[] = $row; } } echo '<pre>'; print_r($items); // $product = array(); echo $rowcount; for ($x=0; $x<$rowcount; $x++){ $scrapeurl[$x] = $items[$x][url]; echo $scrapeurl[$x]; $xpath[$x] = new XPATH($scrapeurl[$x]); $urls[$x] = $xpath[$x]->query("//div[@class='infodata']/strong/a[contains(@id,'test_title')]/@href"); $count[$x] = $urls[$x]->length; $data = array(); for ($i=0; $i<$count[$x]; $i++){ $data[$i]['url'] = $urls[$x]->item($i)->nodeValue; $data[] = $data[$i]['url']; } echo '<pre>'; print_r($data);
$items?