Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

I'm calling $keywords from advanced search but...


lostndazed

Recommended Posts

ok, I'm muddling through this, but am still having a problem with my code. Now it's not showing the string parts in the link to Amazon.

 

In case I hadn't mentioned this before, I'm trying to set up my search result so that if I don't have any products to display, the page will display Amazon's products using the customer's search terms and my affiliate id. There doesn't appear to be a contribution for this feature (yet!).

 

This is what I have so far:

 

========

 

$search_string = $keywords;

$findme = ' '; //looking for empty space

$pos = strpos($search_string, $findme);

 

// Note our use of ===. Simply == would not work as expected

// because the position of first character is 0.

 

if ($pos === false) {

 

// so just go with the $mystring

$list_box_contents = array();

$list_box_contents[0] = array('params' => 'class="productListing-odd"');

$list_box_contents[0][] = array('params' => 'class="productListing-data"',

'text' => TEXT_NO_PRODUCTS . '<br /><iframe src="http://rcm.amazon.com/e/cm?t=$myAmazonID&o=1&p=12&l=st1&mode=music&search=' . $search_string . '&=1&fc1=&lt1=&lc1=&bg1=&f=ifr" marginwidth="0" marginheight="0" width="300" height="250" border="0" frameborder="0" style="border:none;" scrolling="no"></iframe>');

 

} else {

//The string '$findme' was found in the string '$search_string' and exists at position $pos

//Bolded is where I'm having problems.

 

function str_split_index($search_string, $pos) {

$string = (string) $search_string;

$pos = (int) $pos;

 

$prefix = substr($string, 0, $pos);

$suffix = substr($string, $pos);

 

return array($prefix, $suffix);

 

}

 

$list_box_contents = array();

 

$list_box_contents[0] = array('params' => 'class="productListing-odd"');

$list_box_contents[0][] = array('params' => 'class="productListing-data"',

'text' => TEXT_NO_PRODUCTS . '<br /><iframe src="http://rcm.amazon.com/e/cm?t=$myAmazonID&o=1&p=12&l=st1&mode=music&search=' . $prefix . '%20'. $suffix . '&=1&fc1=&lt1=&lc1=&bg1=&f=ifr" marginwidth="0" marginheight="0" width="300" height="250" border="0" frameborder="0" style="border:none;" scrolling="no"></iframe>');

}

 

=======

 

I'm also kind of concerned that even if I get this to work when someone types in two words, will it work when someone types in more than two words?

Link to comment
Share on other sites

Oh shoot! I'm probably doing this all wrong. I just found the explode method of string handling.

 

****tears out the little remaining hair left on my head***

 

I'll come back to this tomorrow morning. Maybe by then someone here will take pity on me. I sure could use some help.

 

*sigh*

Good night all.

Link to comment
Share on other sites

Justme,

 

I am so sorry you went through all that alone. I wish I had the knowledge to have offered you some help.

 

Would you be willing to disclose the code you used ... others might benefit from it.

 

Best of luck to you!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...