Jump to content

mallen

Members
  • Posts

    316
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

mallen's Achievements

Regular Member

Regular Member (3/5)

1

Reputation

2

Community Answers

  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. 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
  6. I found a solution using MySQL full text search in boolean mode that has worked well.
  7. I have been asked to create a more comprehensive search on my website. I have listed products. The table consists of id, name, model, description, watt_range, terms. The problem I have having is if someone searches with multiple words the search won't give results. If I have an item like this. AreaLight2, xyz light, here is the description, 70-100w, area. If someone searches "AreaLight2" it returns the result. If you search "Arealight2 100w" it won't return any results. Can anyone help me point me in the right direction to get this to work? Thanks. Here is the query 'SELECT cat.cat_name, cat.cat_id, prod.prod_id, prod.prod_name, prod.prod_mainImage, prod.prod_description, prod_model, prod.terms FROM `products` as prod LEFT JOIN `category_assoc` AS assoc ON assoc.prod_id = prod.prod_id LEFT JOIN `categories` AS cat ON cat.cat_id = assoc.cat_id WHERE prod.terms LIKE '%Arealight2%' OR LIKE '%100w%' OR prod.prod_name LIKE '%Arealight2%' OR LIKE '%100w%''
  8. I got it solved. I was adding methods below the closing bracket of the class.
  9. Thanks. I just tested that sample code I posted and saw that it worked. Now I need to know why is doesn't on my project. They is just too much to post here. Something must be conflicting. Works without $disp->
  10. If I type it just like this echo $disp->displayTomorrow(); I get Fatal error: Call to undefined method MyDisplay::displayTomorrow()
  11. class MyDisplay { function displayToday() { $today = "Thursday"; { echo $today; } } function displayTomorrow() { $tomorrow = "Friday"; { echo $tomorrow; } } } $disp = new MyDisplay(); echo $disp->displayToday(); echo displayTomorrow();//fails is I have $disp-> I simplified my code for explanation. One class with two methods. When I try to use the method I get this error. Fatal error: Call to undefined method MyDisplay::displayTomorrow()
  12. Seems I got it fixed. $digit .= ($num = $possible_letters[rand(0,strlen($possible_letters)-1)]); I added -1 but I am not sure what the -1 does.
  13. I am working on creating a cusom captcha. It creates a random alphanumeric string. I set the value for the total characters to "5" but sometimes it will only display 4 characters. Is this a result of the rand function? session_start(); error_reporting(E_ALL ^ E_NOTICE); $image = @imagecreatetruecolor(120, 30) or die("Cannot Initialize new GD image stream"); // set background and allocate drawing colours $background = imagecolorallocate($image, 0x66, 0x99, 0x66); imagefill($image, 0, 0, $background); $linecolor = imagecolorallocate($image, 0x99, 0xCC, 0x99); $textcolor1 = imagecolorallocate($image, 0x00, 0x00, 0x00); $textcolor2 = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); $lines = 5; // draw random lines on canvas for($i=0; $i < $lines; $i++) { imagesetthickness($image, rand(1,3)); imageline($image, 0, rand(0,30), 120, rand(0,30) , $linecolor); } $string = ''; $total_characters = 5; $random_dots = 5; $font_size = 16; $possible_letters = '2345678abcdefghjkmnpqrtwyABCDEFGHJKMNPQRTWY'; $fonts = array(); $fonts[] = "fonts/font1.ttf"; $fonts[] = "fonts/font2.ttf"; $fonts[] = "fonts/font3.ttf"; for( $i=0; $i<$random_dots; $i++ ) { imagefilledellipse($image, mt_rand(0,120), mt_rand(0,30), 2, 3, $image_noise_color); } session_start(); $i = 0; $digit = ''; for($x = 15; $x <= 95; $x += 20 ) { while ($i < $total_characters ) { $i++; $x += 15; $textcolor = (rand() % 2) ? $textcolor1 : $textcolor2; $digit .= ($num = $possible_letters[rand(0,strlen($possible_letters))]); imagettftext($image, $font_size, 0, $x, 20, $textcolor, $fonts[array_rand($fonts)], $num);}} $_SESSION['digit'] = $digit; header('Content-type: image/png'); imagepng($image); imagedestroy($image);
×
×
  • 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.