Results 1 to 2 of 2

Thread: How to retrieve database info into tooltip?

  1. #1
    Join Date
    Jul 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to retrieve database info into tooltip?

    1) Script Title: Image w/ description tooltip v2.0

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...agetooltip.htm

    3) Describe problem:

    Hi,
    I want to use this great scrip in my oscommerce store, but I can't find a way to retrieve images from database. I tried several ways but with no luck.

    Code:
    tooltips[0]=[" images/ . $listing['products_image'] . "]
    tooltips[0]=["<?php images/ $listing['products_image'] ;?>"]
    tooltips[0]=["<?php DIR_WS_IMAGES . $listing['products_image'] ;?>"]
    tooltips[0]=["<?php tep_image(DIR_WS_IMAGES . $listings['products_image'], $listings['products_name'] ,POPUP_IMAGE_WIDTH, POPUP_IMAGE_HEIGHT) ;?>"]
    Here is some of the file code:
    Code:
    <?php
    
    define('PRODUCT_LIST_COLUMNS', 3);
    
    
      $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
      
      if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
    ?>
    
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
        <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
      </tr>
    </table>
    <?php
      }
      
      if (tep_not_null($_GET['manufacturers_id'])) {
        $manufacturer_query = tep_db_query(
          "select manufacturers_name
          from " . TABLE_MANUFACTURERS . "
          where manufacturers_id = '" . tep_db_input($_GET['manufacturers_id']) . "';"
        );
        $manufacturer = tep_db_fetch_array($manufacturer_query);
        $info_box_header = $manufacturer['manufacturers_name'];
        if (tep_not_null($_GET['filter_id'])) {
          $category_query = tep_db_query(
            "select cd.categories_name
            from
              " . TABLE_CATEGORIES . " c,
              " . TABLE_CATEGORIES_DESCRIPTION . " cd
            where c.categories_id = '" . tep_db_input($_GET['filter_id']) . "'
            and cd.categories_id = '" . tep_db_input($_GET['filter_id']) . "'
            and cd.language_id = '" . (int)$languages_id . "'"
          );
          $category = tep_db_fetch_array($category_query);
          $info_box_header .= ' &gt; '. $category['categories_name'];
        }
      }
      
      if (tep_not_null($current_category_id)) {
        $category_query = tep_db_query(
          "select cd.categories_name
          from
            " . TABLE_CATEGORIES . " c,
            " . TABLE_CATEGORIES_DESCRIPTION . " cd
          where c.categories_id = '" . (int)$current_category_id . "'
          and cd.categories_id = '" . (int)$current_category_id . "'
          and cd.language_id = '" . (int)$languages_id . "'"
        );
        $category = tep_db_fetch_array($category_query);
        $info_box_header = $category['categories_name'];
      }
      
      $info_box_contents = array();
    //  $info_box_contents[] = array('text' => $info_box_header);
    
    //  new contentBoxHeading($info_box_contents);
    
      $row = 0;
      $col = 0;
      $list_box_contents = array();
      if ($listing_split->number_of_rows > 0) {
        $listing_query = tep_db_query($listing_split->sql_query);
    
        while ($listing = tep_db_fetch_array($listing_query)) {
          
          $lc_align = 'center';
          $lc_text = '<table cellpadding="0" cellspacing="0" border="0">' . "\r\n";
          
          foreach ($column_list as $column) {
            switch($column) {
            
            // Row: Products model
              case 'PRODUCT_LIST_MODEL':
                $lc_text .= '  <tr>' . "\r\n"
                          . '    <td align="center"></td>' . "\r\n"
                          . '  </tr>' . "\r\n";
                break;
    
            // Row: Product's image
              case 'PRODUCT_LIST_IMAGE':
                $lc_text .= '  <tr>' . "\r\n"
                          . '    <td align="center" height="170" valign="bottom"><span class="linephoto"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, (isset($_GET['manufacturers_id']) ? 'manufacturers_id=' . $_GET['manufacturers_id'] : ($cPath ? 'cPath=' . $cPath : '')) . '&products_id=' . $listing['products_id']) . '" rel="imgtip[0]">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></span></td>' . "\r\n"
                          . '  </tr>' . "\r\n";
                break;
              
            // Row: Product's name
              case 'PRODUCT_LIST_NAME':
                $lc_text .= '  <tr>' . "\r\n"
                          . '    <td align="center" height="30" valign="top"><div class="TextHome2"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, (isset($_GET['manufacturers_id']) ? 'manufacturers_id=' . $_GET['manufacturers_id'] : ($cPath ? 'cPath=' . $cPath : '')) . '&products_id=' . $listing['products_id']) . '">&nbsp;' . $listing['products_name'] . '</a><div></td>' . "\r\n"
                          . '  </tr>' . "\r\n";
                break;
                
            // Row: Manufacturer's name
              case 'PRODUCT_LIST_MANUFACTURER':
                $lc_text .= '  <tr>' . "\r\n"
                          . '    <td align="center"></td>' . "\r\n"
                          . '  </tr>' . "\r\n";
                break;
                
            // Row: Price
              case 'PRODUCT_LIST_PRICE':
                if (tep_not_null($listing['specials_new_products_price'])) {
                  $lc_text .= '  <tr>' . "\r\n"
                            . '    <td align="center"></td>' . "\r\n"
                            . '  </tr>' . "\r\n";
                } else {
                  $lc_text .= '  <tr>' . "\r\n"
                            . '    <td align="center"></td>' . "\r\n"
                            . '  </tr>' . "\r\n";
                }
                break;
              
            // Row: Product's quantity
              case 'PRODUCT_LIST_QUANTITY':
                $lc_text .= '  <tr>' . "\r\n"
                          . '    <td align="center"></td>' . "\r\n"
                          . '  </tr>' . "\r\n";
                break;
              
            // Row: Product's weight
              case 'PRODUCT_LIST_WEIGHT':
                $lc_text .= '  <tr>' . "\r\n"
                          . '    <td align="center"></td>' . "\r\n"
                          . '  </tr>' . "\r\n";
                break;
    
            // Row: Buy now button
              case 'PRODUCT_LIST_BUY_NOW':
                $lc_text .= '  <tr>' . "\r\n"
                          . '    <td align="center"></td>' . "\r\n"
                          . '  </tr>' . "\r\n";
                break;
            }
          }
          
          $lc_text .= '</table>' . "\r\n";
          
          $list_box_contents[$row][$col] = array(
            'align' => $lc_align,
            'params' => 'width="'. round(100/PRODUCT_LIST_COLUMNS) .'%" class="productListing-data"',
            'text'  => $lc_text
          );
    
    
        if (($_GET['keywords'] != '')) {
        $search_count = tep_db_query("select search, freq from customers_searches where search = '". $_GET['keywords'] . "' and language_id='". $languages_id . "'");
          if (!tep_db_num_rows($search_count)) {
          tep_db_query("insert into customers_searches (search, freq, language_id) values ('". tep_db_input($_GET['keywords']) ."',1," .$languages_id." )");
           } else {
          $search_val = tep_db_fetch_array($search_count);
          tep_db_query("update customers_searches set freq = " . ($search_val['freq']+1) . " where search = '". tep_db_input($_GET['keywords']) . "' and language_id='". $languages_id . "'");
          }
        }
    
    
          $col ++;
          if ($col > (PRODUCT_LIST_COLUMNS-1)) {
            $col = 0;
            $row ++;
          }
        }
        
        while ($col != 0 && sizeof($list_box_contents[$row]) < PRODUCT_LIST_COLUMNS) {
          $list_box_contents[$row][$col] = array(
            'align' => 'center',
            'params' => 'width="'. round(100/PRODUCT_LIST_COLUMNS) .'%"',
            'text'  => '&nbsp;'
          );
          
          $col ++;
        }
        
        new productListingBox($list_box_contents);
      } else {
        $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);
    
        new productListingBox($list_box_contents);
      }
    
      if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
    ?>
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
        <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
      </tr>
    </table>
    <?php
      }
    ?>
    	<script language="javascript" type="text/javascript">
    
    
    var ddimgtooltip={
    
    	tiparray:function(){
    		var tooltips=[]
    
    
            tooltips[0]=["<?php DIR_WS_IMAGES . $listing['products_image'] ;?>"]
    Thank you very much in advance.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    From what I can tell, you just aren't actually outputting anything from the PHP. This isn't a problem with the script, but with your PHP's output, so you need to view the generated source code in order to find the problem.

    <?php echo EXPRESSION; ?>

    That should be all you need to do. But then you'll also, of course, need to add the other parameters for the Javascript function as needed.

    What I recommend is:
    tooltips[0]=["<?php echo $var1; ?>","<?php echo $var2; ?>", .... ];
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •