Jump to content



drferrari

Member Since 17 Apr 2007
OFFLINE Last Active Apr 15 2014 10:14 AM
-----

Posts I've Made

In Topic: multiple select menu - categories.php - insert values to table

02 March 2014 - 08:11 PM

@wHiTeHaT yes I will send my code soon.

In Topic: multiple select menu - categories.php - insert values to table

27 February 2014 - 11:24 PM

when I select in multiple select menu: 2 values  - 1) cotton 50%, 2) cotton 100%.

I try pass this 2 values to:
$sql_data_materials_array = array('materials_id' => tep_db_prepare_input($HTTP_POST_VARS['materials_id']));
and then $sql_data_materials_array goes to:

if ($action == 'insert_product') {
		 $insert_sql_data = array('products_date_added' => 'now()');

		 $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
		 tep_db_perform(TABLE_PRODUCTS, $sql_data_array);
		
		 $products_id = tep_db_insert_id();
		 $insert_sql_data = array('products_id' => $products_id);

		 $sql_data_materials_array = array_merge($insert_sql_data, $sql_data_materials_array);
		 tep_db_perform(TABLE_PRODUCTS_TO_MATERIALS, $sql_data_materials_array);

		 tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");
		 }

In mysql Table (products_to_materials) products_id is ok, THE PROBLEM is with materials_id column here the code add only the last materials_id (number 2), but I wanna add for products_id 1 add materials_id 1 and another record products_id 1 and materials_id 2.

can anybody help.

In Topic: multiple select menu - categories.php - insert values to table

27 February 2014 - 07:39 PM

I try in admin/categories.php add with multiple select menu to new product some extra value e.g.
cotton 50% and cotton 100% and save it to mysql table:

products_to_materials
_________________________________
|   products_id |  materials_id |
---------------------------------
you also have this table:
products_materials
_______________________________________________
| materials_id | materials_name | language_id |
--------------------------------------------------
| 1                       | cotton 50% |    1    |
--------------------------------------------------
| 2                        | cotton 100%   |    1    |
--------------------------------------------------

In Topic: View all products in Categories

27 February 2014 - 02:07 PM

change this:
while ($categories = tep_db_fetch_array($categories_query)) {
	  $rows++;
	  $cPath_new = tep_get_path($categories['categories_id']);
	  $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
	  echo '		<td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '"></a></td>' . "\n";
	  if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
		echo '	  </tr>' . "\n";
		echo '	  <tr>' . "\n";
	  }
	}

to this:
while ($categories = tep_db_fetch_array($categories_query)) {
	  $rows++;
	  $cPath_new = tep_get_path($categories['categories_id']);
	  $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
		   echo '<td align="center" width="' . $width . '" valign="top">

<table border="0" width="100%" cellspacing="4" cellpadding="4">
<tr>
<td width="100%" align="center"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">
' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a></td>
</tr>
<tr>
<td width="100%" align="center"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'. $categories['categories_name'].'</a></td>
</tr>

</table>
</td>';
	  
	  if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
		echo '			  </tr>' . "\n";
		echo '			  <tr>' . "\n";
	  }
	}

In Topic: View all products in Categories

27 February 2014 - 01:08 PM

index.php search for (Line 100 - 170)

after:
if (isset($cPath) && strpos('_', $cPath)) { }else{

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.categories_status, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and c.categories_status = 1 and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");

and see if you have limit in end of query