Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How do i call a variable from the database?


dimports

Recommended Posts

Posted

I'm trying to call the products model from the database but it doesnt work. This is from my product_listing.php mod. Heres what I tried:

 

$products_model = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $listing_values['products_id'] . "'");

 

and

 

$products_model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $listing_values['products_id'] . "'");
$products_model = tep_db_fetch_array($products_model_query);

 

In case you need to see the rest of the document, here the the rest of the code. Thanks in advance for any help.

<?php
DEFINE('PRODUCT_LIST_COL_NUM',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>
<tr>
<td colspan=2 align="center">
<img src="images/dot.gif" width="775" height="1" border="0" align="middle">
</td>
</tr>
</table>
<table width="775" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="50">
<img src="images/blank.gif" width="50">
</td>
<td>
<br>

<?php
 }
 $info_box_contents = array();

 if ($listing_split->number_of_rows > 0) {

$row = 0;
$col = 0;

   $listing = tep_db_query($listing_split->sql_query);
   while ($listing_values = tep_db_fetch_array($listing)) {

     $listing_values['products_name'] = tep_get_products_name($listing_values['products_id']);


$products_model = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $listing_values['products_id'] . "'");

   
     $lc_text= '<img src="images/dot.gif" width="177" height="1" border="0"><br>
<img src="images/dot.gif" width="1" height="175" border="0"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing_values['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing_values['products_image'], $listing_values['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><img src="images/dot.gif" width="1" height="175"
border="0"><br><img src="images/dot.gif" width="177" height="1" border="0" align="top"><br><img src="images/pshadow.gif" width="177" height="12" border="0"><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing_values['products_id']) . '"><u><SPAN STYLE="font-size: 8pt">' . $listing_values['products_name'] . '</span></u></a><br>';
//***** START OF B2BSUITE

                                         $customer_group_query = tep_db_query("select customers_group_id from " . TABLE_CUSTOMERS . " where customers_id =  '" . $customer_id . "'");
                                         $customer_group = tep_db_fetch_array($customer_group_query);
                                         $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $listing_values['products_id'] . "' and customers_group_id =  '" . $customer_group['customers_group_id'] . "'");
                                           if ( $customer_group['customers_group_id'] != 0) {
                                           if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
                                         //$listing = "";
                                                       $listing_values['products_price'] = $customer_group_price['customers_group_price'];
                                                }
                                                }
//***** END OF B2BSUITE
           $listing_values['specials_new_products_price'] = tep_get_products_special_price($listing_values['products_id']);//B2Bsuite   
if ($listing_values['specials_new_products_price']) {
 
$products_price_s = ' <s><i>' .  $currencies->display_price($listing_values['products_price'], tep_get_tax_rate($listing_values['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing_values['specials_new_products_price'], tep_get_tax_rate($listing_values['products_tax_class_id'])) . '</i></span> <br><br><br>';

  	 if (PRICES_LOGGED_IN == 'false') {
 if($listing_values['products_price'] > 0) {
	 $product_price_d = $products_price_s;
 } else {
 $product_price_d = "<a href=\"mailto:[email protected]?subject=Pricing Inquiry: " . $products_model . "\"><SPAN STYLE=\"font-size: 8pt\"> <i>Email for pricing...</i></span></a><br><br><br>";
 }
}


  	 if ((PRICES_LOGGED_IN == 'true') && (!tep_session_is_registered('customer_id'))) {
 $product_price_d = ('<a href="' . tep_href_link(FILENAME_LOGIN, '','SSL') . '"><SPAN STYLE=\"font-size: 8pt\"><i>'  . PRICES_LOGGED_IN_TEXT . '...</i></span></a><br><br><br>' );
} else {
	 if($listing_values['products_price'] > 0) {
   $product_price_d = $products_price_s;
	 } else {
$product_price_d = "<a href=\"mailto:[email protected]?subject=Pricing Inquiry: " . $products_model . "\"><SPAN STYLE=\"font-size: 8pt\"> <i>Email for pricing...</i></span></a><br><br><br>";
}
}


       $lc_text =  $product_price_d;

} else {
       $products_price_s = ' <i>' . $currencies->display_price($listing_values['products_price'], tep_get_tax_rate($listing_values['products_tax_class_id'])) . '</i> <br><br><br>';
       
if (PRICES_LOGGED_IN == 'false') {
 if($listing_values['products_price'] > 0) {
	 $product_price_d = $products_price_s;
 } else {
 $product_price_d = "<a href=\"mailto:[email protected]?subject=Pricing Inquiry: " . $products_model . "\"><SPAN STYLE=\"font-size: 8pt\"> <i>Email for pricing...</i></span></a><br><br><br>";
 }
}
   
if ((PRICES_LOGGED_IN == 'true') && (!tep_session_is_registered('customer_id'))) {
$product_price_d = ('<a href="' . tep_href_link(FILENAME_LOGIN, '','SSL') . '"><SPAN STYLE=\"font-size: 8pt\"><i>'  . PRICES_LOGGED_IN_TEXT . '...</i></span></a><br><br><br>' );
} else {
 if($listing_values['products_price'] > 0) {
	 $product_price_d = $products_price_s;
 } else {
 $product_price_d = "<a href=\"mailto:[email protected]?subject=Pricing Inquiry: " . $products_model . "\"><SPAN STYLE=\"font-size: 8pt\"> <i>Email for pricing...</i></span></a><br><br><br>";
 }
}

$lc_text.=  $product_price_d;
}


     $info_box_contents[$row][$col] = array('align' => 'left', 'params' => 'class="smallText" width="33%" valign="top"',
                                          'text' => $lc_text);

     $col ++;
     if ($col > PRODUCT_LIST_COL_NUM-1) {
       $col = 0;
       $row ++;
     }
   }

   new contentBox($info_box_contents);

 } else {

   $info_box_contents = array();

   $info_box_contents[0] = array('params' => 'class="productListing-odd"');
   $info_box_contents[0][] = array('params' => 'class="productListing-data"',
                                  'text' => TEXT_NO_PRODUCTS);

   new contentBox($info_box_contents);

 }

if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
 ?>
</td>
</tr>
</table>
<table width="100%">
<tr>
<td align="center" colspan="2">
<img src="images/dot.gif" width="775" height="1" border="0" align="middle">
</td>
</tr>
  <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
 }
?>

Archived

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

×
×
  • Create New...