PHP HTML Dom Parser

		$counter = 0;
		foreach($header as $url) {
			if ($counter>1) { // counter has set if content is empty/null. Here if counter greater than one contents will be displayed too.
					$item['image'] = $url->find('a',0)->href;		
					$item['airline'] = $url->find('span',0)->plaintext;
					$item['flight'] = $url->find('span',1)->plaintext;
					$item['ac'] = $url->find('span',2)->plaintext;
					$item['arrived'] = $url->find('span',3)->plaintext;
					$item['time'] = $url->find('span',4)->plaintext;
					$item['expected'] = $url->find('span',5)->plaintext;
					$item['remark'] = $url->find('span',6)->plaintext;			
					$a[] = $item; 
					// inserting content from web page to database after clearing HTML
						$query = "INSERT INTO live_flight (image, airline, flight, ac, arrived, time, expected, remark)
						$result = mysql_query($query);
			while($row = mysql_fetch_array($result1)) {			
					$str = str_replace(' ', '', $row['remark']);				
					$sr = str_replace('On Time', '',$str);									
					$s = str_replace('Delay', 'late by', $sr);
					$ar = explode(" ", $s);
					$me = strtolower($row['arrived']);
					$mea = ucwords($me);
					$z = $row['image'];
					echo &quot;<tr>";
					echo  "<td>"."<a href='$z'>".$mea."</a>"."</td>".
						  "<td>".$row['time']." "."</td>".
						  "<td>".$ar[0]. ' '.human_time($ar[1])."</td>";
					echo "</tr>"; 					 	

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s