Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6718753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:00:32+00:00 2026-05-26T09:00:32+00:00

Can anyone tell why the second if statement pulling the soldby name wouldn’t work

  • 0

Can anyone tell why the second if statement pulling the soldby name wouldn’t work properly?

What I want it to do is name pull the alt attribute from the image, if there is an image for the seller – which works. But if there isn’t an image logo, there is a bold tag with the seller name which I want to be inserted in the same place in the array that the alt tag would be.

The HTML I am working with is: http:// amazon.com/gp/offer-listing/B002UYSHMM

Can anyone help?

Thank you!

$item = array();

foreach ($html->find('div.resultsset table tbody.result tr') as $article) { 
  if ($article->find('span.price', 0)) {  
    // get retail  
    $item[$retail.$i++] = $article->find('span.price', 0)->plaintext;  
    // get soldby
    if ($article->find('ul.sellerInformation img', 0)) {
      $item[$soldby.$j++] = $article->find('ul.sellerInformation img', 0)->getAttribute('alt');
    } else {
      $item[$soldby.$j++] = $article->find('ul.sellerInformation li a b', 0)->plaintext;
    }
    $ret['SellerInfo'] = $item;
  }
}

Here is the array I get out of my code above:

 Array ( [0] => Array ( [Retail] => $219.88 [SoldBy] => J&R Music and Computer World ) [1] => Array ( [Retail] => $234.21 [SoldBy] => PORTABLE GUY ) [2] => Array ( [Retail] => $235.73 [SoldBy] => The Price Pros ) [3] => Array ( [Retail] => $234.74 [SoldBy] => GizmosForLife ) [4] => Array ( [Retail] => $230.00 [SoldBy] => ) [5] => Array ( [Retail] => $198.73 [SoldBy] => ) [6] => Array ( [Retail] => $240.72 [SoldBy] => ) [7] => Array ( [Retail] => $248.99 [SoldBy] => onSale ) ) 

You can see that it is missing SoldBy for:

STEPHS GREAT BOOK TREASURES

Diakonos23

OptimumHouse

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:00:33+00:00Added an answer on May 26, 2026 at 9:00 am

    Figured it out:

    foreach($html->find('div.resultsset table tbody.result tr') as $article) { 
    if($article->find('span.price', 0)) {  
    // get retail  
    $item['Retail'] = $article->find('span.price', 0)->plaintext;  
    // get soldby  
    if($article->find('img', 0)->getAttribute('alt') <> '') {
    $item['SoldBy'] = $article->find('img', 0)->getAttribute('alt'); }
    else {$item['SoldBy'] = $article->find('ul.sellerInformation li a b', 0)->plaintext;}
    $ret[] = $item; 
     }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me why the second cast fails to compile in Delphi 7?
Can anyone tell me how can I get the xpath of the name attribute
Can anyone tell me how to work with the parameters stored in the value
Can anyone tell me how can i create two business accounts? Actually, i want
Can anyone tell my why this wouldn't compile? package main type myint int func
Can anyone tell me why the following won't work? It complains of a syntax
http://itunes.apple.com/app/bloomberg/id281941097?mt=8 On the second screenshot or this Bloomberg iPhone app.. Can anyone tell me
Can anyone tell me how I can display a status message like 12 seconds
Can anyone tell me how to format a given number of seconds (for example
Can anyone tell me what is the memory usage overhead associated with PHP opcode

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.