Jump to content

double up while loop problem


samoht

Recommended Posts

hello all,

 

I want to set up a thumbnail viewer for different products in my store. currently I have a function that grabs all the thumbs  - now I need to add the css so that on hover the thumb is enlarged. I thought I could just add a while loop to the same function but that doesn't seem to work

 

??

 

here is my function:

function list_thumb_drop( $product_id, $cls_suffix ) {

	global $VM_LANG, $CURRENCY_DISPLAY, $mm_action_url, $sess ;

	require_once (CLASSPATH . 'ps_product.php') ;
	$ps_product = new ps_product( ) ;
	$Itemid = $sess->getShopItemid() ;
	$category_id = vmGet( $_REQUEST, 'category_id', "" ) ;
	$db = new ps_DB( ) ;
	$db_sku = new ps_DB( ) ;
	$db_item = new ps_DB( ) ;
	$tpl = new $GLOBALS['VM_THEMECLASS']( ) ;
	$tpl->set( "cls_suffix", $cls_suffix ) ;
	$tpl->set( "product_id", $product_id ) ;
	// Set Advanced Attributes
	$tpl->set( "advanced_attribute", $this->list_advanced_attribute( $product_id, $db->f( "product_id" ) ) ) ;
	$tpl->set( "custom_attribute", $this->list_custom_attribute( $product_id, $db->f( "product_id" ) ) ) ;
	// Get list of children
	$q = "SELECT product_id,product_name,file_name FROM #__{vm}_product, #__{vm}_product_files WHERE product_parent_id='$product_id' AND product_id = file_product_id AND product_publish='Y'" ;
	$db->query($q);

	if( $db->num_rows() < 1 ) {
		// Must be a child then
		$child_id = $product_id;
		// Try to Get list of sisters & brothers
		$product_parent_id = $ps_product->get_field( $product_id, 'product_parent_id' ) ;
		if( $product_parent_id != "0" ) {
			$product_id = $product_parent_id;
			$q = "SELECT a.product_id,a.product_name,b.file_name FROM #__{vm}_product a, #__{vm}_product_files b WHERE a.product_parent_id=$product_id AND a.product_parent_id<>0 AND a.product_publish='Y'" ;
			$db->setQuery( $q ) ;
			$db->query() ;
		}
	}
	/*if( $db->num_rows() > 0 ) {
		$css = '<style type="text/css">';
		$css .= 'a.gallery, a.gallery:visited {display:inline; color:#000; text-decoration:none; border:1px solid #000; width:75px; height:75px; float:left; margin:7px 21px; position:relative; cursor:default;}';
		while( $db->next_record() ) {
			$selected = isset( $_REQUEST['product_id'] ) ? ($db->f( "product_id" ) == $_REQUEST['product_id'] ? 'selected="selected"' : '') : '' ;

			//start row for each slide
			$css .= 'a.slide'.$i.'{background:url('. $db->f( "file_name" ). ');}'."\n";
		}

                  $css .= '</style>';
	}*/	

	if( $db->num_rows() > 0 ) {
		$flypage = $ps_product->get_flypage( $product_id ) ;
		$html = "<input type=\"hidden\" name=\"product_id\" value=\"$product_id\" />" ;
		// here we go!!
		$html .= "<strong>Available in <br /></strong>\n";
		$html .= '<div class="avilable">'."\n";
		$i = 0;
		while( $db->next_record() ) {
			$selected = isset( $_REQUEST['product_id'] ) ? ($db->f( "product_id" ) == $_REQUEST['product_id'] ? 'selected="selected"' : '') : '' ;


			// Start row for this child --- need to get the correct hover code here !!
			$html .= '<span><a class="gallery slide'.$i.'" href="#nogo" title="'.$db->f( "product_name" ).'" ><span>';
			$html .= "<img src=\"". $mm_action_url . $db->f( "file_name" ). "\" /></span></a></span>\n" ;
			$i++;
		}
		$tpl->set( "drop_down", $html ) ;
	}
	return array( $html , "drop" ) ;
}

 

and you can see the commented out portion is the loop I tried to add for the css

 

Any help??

Link to comment
https://forums.phpfreaks.com/topic/109952-double-up-while-loop-problem/
Share on other sites

ok,

 

I reset my db

$db->reset();

 

which solved half the problem  - but I still am unable to retreive the $css from the function. I tried adding it to my return value like so:

 

return array ($html , "drop" , $css );

 

but this doesn't work. Any thoughts??

 

Thanks

Archived

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

×
×
  • 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.