Jump to content

PHP Simple HTML DOM Parser proplem


tazeha

Recommended Posts

Hello

 

I using PHP Simple HTML DOM Parser .

 

Now I write the mini script .

 

This script find the products online shopping with price.

 

but one problem is.

<?phpinclude_once('simple_html_dom.php');// Create DOM from URLheader("Refresh: 300;");$html = file_get_html('http://wpu.ir/v3128');$articles = array();// Find all article blocksforeach($html->find('div#content') as $article) {    $item['title']     = $article->find('h1', 0)->plaintext;    $item['intro']    = $article->find('h3', 0)->plaintext;    $item['details'] = $article->find('span.finalprice', 0)->plaintext;    $articles[] = $item;}echo $title="<b>نام محصول:</b>". $item['title'] . "</br>  ";echo  $dec="<b>توضیحات:</b> ". $item['intro'] . "</br> "; echo $pr="<b>قیمت:</b> ". $item['details'] . " </br> ";  //to fetch all images from a webpage$images = array();foreach($html->find('img') as $img) { $images[] = $img->src;}echo " $images[29]";?> 

the product's detail's.

 

name

 

price

 

image

 

description

 

...

 

in this loop

foreach($html->find('img') as $img) { $images[] = $img->src;}echo " $images[29]"; 

only display the image url not imge.

 

please help

 

Link to comment
Share on other sites

put the src an image tag.

echo '<img src="' . $images[29] . '" />';

make sure 29 is a valid index

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

how save price with product name in database mysql..

please make a new thread / post if you have a new question different from the first post of this thread

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...