Jump to content

mallen

Members
  • Posts

    316
  • Joined

  • Last visited

Everything posted by mallen

  1. Thanks I was looking at it so long i missed that. The concatenating (sp) was because my original code had more to out put. I just had the echo in the wrong place.
  2. function getSimilarProducts() { global $wpdb; $out =""; $Simprod = "SELECT DISTINCT (pr.prod_id), pr.prod_image FROM products as pr LEFT JOIN category_assoc as assoc ON assoc.prod_id = pr.prod_id WHERE pr.companyB = '1' AND assoc.cat_id = '28' AND pr.prod_active = '1' LIMIT 3"; $SIM = $wpdb->get_results($Simprod, ARRAY_A); echo "These are similar products you may like."; foreach($SIM as $sample) { $out .= "<img src='". $this->imgLink . "/".$sample['prod_image']. "' />"; echo $out; } } I have a simple query I tested in phpmyAdmin. Returns the limit results I need. But when I run my function I get duplicates, it returns 6 results all the same ID.
  3. $THEURL = "SELECT Image_URL From ... ect";//the query $image = $wpdb->get_row($THEURL, ARRAY_A);//the variable is dynamic var_dump(substr(strrchr($image,'/'),1)); fails var_dump(substr(strrchr('http://somewebsite.com/images/image1.jpg','/'),1)); gives 'image1.jpg' var_dump($image); // gives 'http://somewebsite.com/images/image1.jpg' I figured it out: var_dump(substr(strrchr($image['Image_URL'],'/'),1));
  4. Ok I am following you. But in your example you assigned a value to $image. But I already have a value to $image. And if I dump it is gives me the string. So I need to do the reverse. $image = 'http://somewebsite.com/images/image1.jpg';
  5. Yes still getting boolean false
  6. I am getting boolean false
  7. I'm trying to take the value and pick out everything after the trailing slash. I tested and the variable is correct. On the third line I can't figure out how to format it. var_dump($image);// http://somewebsite.com/images/image1.jpg var_dump(substr(strrchr('http://somewebsite.com/images/image1.jpg', '/'), 1)); //image1.jpg var_dump(strrchr(strrchr('$image','/'),1));//getting false
×
×
  • 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.