Jump to content

magnusalex

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Everything posted by magnusalex

  1. Hi, I am having some trouble with a rewrite of a URL from a ZenCart store to an external URL. The URL I want to rewrite: http://www.store.com/index.php?main_page=product_info&cPath=123_456&products_id=13286 My rewrite condition: RewriteCond %{query_string} ^products_id=13286$ RewriteRule (.*) http://www.domain.com/product.htm [R=301,L] However, I cant get that to work. If I remove the ^ and $ from the RewriteCond the rewrite works (I thought they had to be there...), but I get a result URL looking like this: http://www.domain.com/product.htm?main_page=product_info&cPath=123_456&products_id=13286 How can I disable/skip the passing of variables?
  2. Hm... About the word-length, why do I get results that all contains AA or AAA, but not Procell, if AA or AAA is too short? Do you think I should try changing the ft_min_word_len setting? Ok, changed it to this like dreamwest's code: $q=$_POST['searchword']; foreach(explode(' ',$q) as $word) $q .= "+{$word}* "; $sql_res = mysql_query("SELECT * FROM test_user_data WHERE MATCH streng AGAINST ('$q' IN BOOLEAN MODE) ORDER BY streng LIMIT 5" ); Correct? By removing the % in the query I often get unexpected results. For example "Inspiron Dell 6000" gives hits on both dell and 6000, but not inspiron... Try that in the url above and you'll see. For reference: In my DB i have the "streng" coloum set at FULLTEXT index, and type "text". Again: Thank you so much for your time!
  3. But that would require the user to write his search with the separators and/or/both? I am afraid that is not something I could use... My client runs a store that sells batteries. If a customer wants a new battery for his Dell Inspiron 6000, I can't require him to write his search like "+Dell +Inspiron +6000". If there is another way, I would really love to hear the idea! I have an example of the searchbox here: http://himmelriket.org/example/ The entire file that generates the results: <?php include 'configuration.php'; if($_POST) { $q=$_POST['searchword']; foreach(explode(' ',$q) as $word) $q2 .= "+{$word}* "; $sql_res = mysql_query("SELECT * from test_user_data WHERE MATCH streng AGAINST('%$q2%' IN BOOLEAN MODE) OR MATCH sku AGAINST('%$q2%' IN BOOLEAN MODE) ORDER BY streng LIMIT 5"); //The original query, not able to pick up multiple words //$sql_res=mysql_query("select * from test_user_data where streng like '%$q%' or beskrivelse like '%$q%' or sku like '%$q%' order by streng LIMIT 5"); while($row=mysql_fetch_array($sql_res)) { $streng=$row['streng']; $beskrivelse=$row['beskrivelse']; $bilde=$row['bilde']; $url=$row['url']; $re_streng='<b>'.$q.'</b>'; $re_beskrivelse='<b>'.$q.'</b>'; $final_streng = str_ireplace($q, $re_streng, $streng); $final_beskrivelse = str_ireplace($q, $re_beskrivelse, $beskrivelse); ?> <div class="display_box" align="left" onclick="location.href='<?php echo $url; ?>';" style="cursor:pointer;"> <img src="<?php echo $bilde; ?>" style="width:25px; float:left; margin-right:6px" /><?php echo $final_streng; ?><br/> <span style="font-size:9px; color:#999999"><?php echo $final_beskrivelse; ?></span></div> <?php } } else { } ?> If you try with the searchword "duracell aaa procell" you will not get any results, i think that there must be an error somewhere. The content of that product "streng" cell is "Duracell Procell AAA 1,5V Alkaline". Thank you so much for your time!
  4. Thank you, again! But I am getting some strange behavior... This is another few of the cell values from my database: 2HR-AAAU battery 90.AA202.001 Compatible battery AAAx3 Compatible battery AACR50100001K0 Compatible battery AACR50100001K2 Compatible battery 9V Alkaline Duracell Procell Duracell Procell AA 1,5V Alkaline Duracell Procell AAA 1,5V Alkaline Duracell Procell C 1,5V Alkaline Duracell Procell D 1,5V Alkaline By doing this query: SELECT * from test_user_data WHERE MATCH streng AGAINST('%+procell*%' IN BOOLEAN MODE) ORDER BY streng LIMIT 5 I get this result: 9V Alkaline Duracell Procell Duracell Procell AA 1,5V Alkaline Duracell Procell AAA 1,5V Alkaline Duracell Procell C 1,5V Alkaline Duracell Procell D 1,5V Alkaline Wich is correct. When doing this query: SELECT * from test_user_data WHERE MATCH streng AGAINST('%+procell* +aa*%' IN BOOLEAN MODE) ORDER BY streng LIMIT 5 I would expect it to return: Duracell Procell AA 1,5V Alkaline Duracell Procell AAA 1,5V Alkaline But in reality, it returns this: 2HR-AAAU battery 90.AA202.001 Compatible battery AAAx3 Compatible battery AACR50100001K0 Compatible battery AACR50100001K2 Compatible battery ... wich has nothing to do with the word "procell" at all. Is it forgetting the word? My complete code that you helped me with up to now is like this: $q=$_POST['searchword']; foreach(explode(' ',$q) as $word) $q2 .= "+{$word}* "; $sql_res = mysql_query("SELECT * from test_user_data WHERE MATCH streng AGAINST('%$q2%' IN BOOLEAN MODE) ORDER BY streng LIMIT 5"); If anyone could helt getting this right, I will be more than happy to donate some cash your way!
  5. Hm... Just one more thing: My SQL table coloumn "streng" have these values (and 200.000 more): 310-3543 Dell P 1500 compatible toner 6000 pages 310-5402 Dell P 1700 compatible toner 6000 pages 593-10239 Dell P 1720 compatible toner 6000 pages Dell Inspiron 6000 Compatible battery Dell Inspiron 6000 Original battery If I run this query: SELECT * from test_user_data WHERE MATCH streng AGAINST('{+inspiron +dell +6000}' IN BOOLEAN MODE) ORDER BY streng LIMIT 5 I will get this result: 310-3543 Dell P 1500 compatible toner 6000 pages 310-5402 Dell P 1700 compatible toner 6000 pages 593-10239 Dell P 1720 compatible toner 6000 pages Dell Inspiron 6000 Compatible battery Dell Inspiron 6000 Original battery But if I swap position of the words in the query to this: SELECT * from test_user_data WHERE MATCH streng AGAINST('{+dell +6000 +inspiron}' IN BOOLEAN MODE) ORDER BY streng LIMIT 5 This is my result: Dell Inspiron 6000 Compatible battery Dell Inspiron 6000 Original battery How is that possible? How come it returns hits without the word inspiron in the first query?
  6. Got it to work! Using fulltext does not seem to make any difference. I tried the query directly in phpMyAdmin as well to see the raw result - it's exacly the same with and without fulltext. Thank you so much!
  7. Ah, thanks! Do you happen to know how to make that require all the words in the same cell? Like it is now it prints hits from all of the words searched. All the hits for Dell, all hits for Inspiron, all hits for 6000 etc... I really appreciate your help!
  8. Hi, I am currently using this code as part of my search module: $sql_res = mysql_query("SELECT * from test_user_data WHERE streng like '%$q%' or beskrivelse like '%$q%' or sku like '%$q%' ORDER BY streng LIMIT 5"); Simple code that works if my client searches for a string (or part of) that is contained in test_user_data table. If he searches "Dell Inspiron 6000", he will get a hit. However, if he searches for "Inspiron Dell 6000", he will not. Is it a simple way to make the client/enduser search for multiple words contained in a single cell? Thank you! This forum is awesome!
  9. Hi, I have an array filled with values like this: string(1) "Acer 1" string(2) "Acer 2" string(3) "Dell 1" string(4) "Dell 2" string(5) "Dell 3" string(6) "Dell 4" string(7) "Acer 3" string( "Acer 4" Is there a way to successfully remove all array strings that starts with a given value like "Acer"? I tried with this snippet, does not work: foreach($array as &$value) { if(preg_match("/^Acer/", $value)) { unset($value); } } Any ideas will be appreciated!
  10. I see that now... sorry about that! This solution works like a charm! Thank you very much!
  11. Thank you! I can however, not get it to work properly... It still prints as several arrays. I put the code here: while($row = mysql_fetch_array($run_mysql_query)){; $models = $row['text_value']; $attribute1 = $row['attribute1']; $attribute2 = $row['attribute2']; $array = explode(',', $models); foreach($array as &$value) { $value = $row['varchar_value'] . " - " . $value . " - " . $attribute1 . " - " . $attribute2; } $newArray = array(); foreach ( $array as $val ) { $newArray = array_merge($newArray, $val); } print_r($newArray); } Is that correct? If I put it outside the while loop, it will only print the last of the arrays...
  12. Hi, I have this problem I really hope someone can help me with. I have a variable that stores several arrays. The content of the variable is as follows: print_r(array_values($array)); Array ( [0] => Value 0) [1] => Value 1) [2] => Value 2) [3] => Value 3) ) Array ( [0] => Value 4) [1] => Value 5) [2] => Value 6) [3] => Value 7) [4] => Value ) Array ( [0] => Value 9) [1] => Value 10) [2] => Value 11) [3] => Value 12) [4] => Value 13) ) Is there a way to join this multiple arrays into a single array? I do not need to keep the Key, as all of the values contains text that I only want to sort with sort();. If I sort it like this, it will only come out as a,b,c,d - a,b,c,d, not a, a, b, b, c, c, d, d and so forth. The php script that creates this array is as follows: while($row = mysql_fetch_array($run_mysql_query)){; $models = $row['text_value']; $attribute1 = $row['attribute1']; $attribute2 = $row['attribute2']; $array = explode(',', $models); foreach($array as &$value) { $value = $row['varchar_value'] . " - " . $value . " - " . $attribute1 . " - " . $attribute2; } I will appreciate any help!
×
×
  • 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.