Hey everyone i have a big problem.
I'am busy adjusting the script's of theexchangeproject shop for our own shop.
We have a heuge database with products and it's the intention to show them in groups of 10.
The script allows a max result with the search engine but when i set it to ten
it won't display a button with next results.
In subcategories it is even worse there is no max result at all and it wil display everything that is in the subcategorie.
I have put the script parts in here for you to see i'am just starting with php and this is going to far for me.
Search script:
$row = 0;
$search = tep_db_query("select manufacturers.manufacturers_name, manufacturers.manufacturers_location, products.products_id, products.products_name, products.products_price from manufacturers, products_to_manufacturers, products where products_to_manufacturers.products_id = products.products_id and products_to_manufacturers.manufacturers_id = manufacturers.manufacturers_id and (products.products_name like '%" . $HTTP_POST_VARS['query'] . "%' or manufacturers.manufacturers_name like '%" . $HTTP_POST_VARS['query'] . "%') order by products.products_name limit " . MAX_DISPLAY_SEARCH_RESULTS);
while ($search_values = tep_db_fetch_array($search)) {
$row++;
$products_name = tep_products_name($search_values['manufacturers_location'], $search_values['manufacturers_name'], $search_values['products_name']);
if (floor($row/2) == ($row/2)) {
echo ' <tr bgcolor="#ffffff">' . "\n";
} else {
echo ' <tr bgcolor="#f4f7fd">' . "\n";
}
echo ' <td nowrap><font face="' . SMALL_TEXT_FONT_FACE . '" size="' . SMALL_TEXT_FONT_SIZE . '" color="' . SMALL_TEXT_FONT_COLOR . '"> <a href=http://www.phpbuilder.com/board/archive/index.php/"' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $search_values['products_id'], 'NONSSL') . '">' . $products_name . '</a> </font></td>' . "\n";
echo ' <td align="right" nowrap><font face="' . SMALL_TEXT_FONT_FACE . '" size="' . SMALL_TEXT_FONT_SIZE . '" color="' . SMALL_TEXT_FONT_COLOR . '"> FL. ' . $search_values['products_price'] . ' </font></td>' . "\n";
echo ' </tr>' . "\n";
}
?>
Results scripts:
<?
$listby_query = tep_db_query("select sql_select from category_index where category_index_id = '" . $HTTP_GET_VARS['index_id'] . "'");
$listby_values = tep_db_fetch_array($listby_query);
$listby = $listby_values['sql_select'];
// we need to look for the sort location of manufacturers_name<>products_name - this method is not the best but it works for now
$sort_location = tep_db_query("select manufacturers.manufacturers_location from products, manufacturers, products_to_manufacturers, products_to_subcategories where products_to_" . $listby . "." . $listby . "_id = '" . $HTTP_GET_VARS['subcategory_id'] . "' and products_to_subcategories.products_id = products.products_id and products.products_id = products_to_manufacturers.products_id and products_to_manufacturers.manufacturers_id = manufacturers.manufacturers_id order by manufacturers.manufacturers_name, products.products_name");
$sort_location_values = tep_db_fetch_array($sort_location);
if ($sort_location_values['manufacturers_location'] == '0') { // the location of manufacturers name is to the left of the products name
$listing = tep_db_query("select products.products_id, products.products_name, manufacturers.manufacturers_name, manufacturers.manufacturers_location, products.products_price from products, manufacturers, products_to_manufacturers, products_to_subcategories where products_to_" . $listby . "." . $listby . "_id = '" . $HTTP_GET_VARS['subcategory_id'] . "' and products_to_subcategories.products_id = products.products_id and products.products_id = products_to_manufacturers.products_id and products_to_manufacturers.manufacturers_id = manufacturers.manufacturers_id order by manufacturers.manufacturers_name, products.products_name");
} else { // its to the right..
$listing = tep_db_query("select products.products_id, products.products_name, manufacturers.manufacturers_name, manufacturers.manufacturers_location, products.products_price from products, manufacturers, products_to_manufacturers, products_to_subcategories where products_to_" . $listby . "." . $listby . "_id = '" . $HTTP_GET_VARS['subcategory_id'] . "' and products_to_subcategories.products_id = products.products_id and products.products_id = products_to_manufacturers.products_id and products_to_manufacturers.manufacturers_id = manufacturers.manufacturers_id order by products.products_name, manufacturers.manufacturers_name");
}
tep_db_free_result($sort_location); // lets free the result from memory..
$number_of_products = '0';
if (tep_db_num_rows($listing)) {
while ($listing_values = tep_db_fetch_array($listing)) {
$number_of_products++;
if (($number_of_products / 2) == floor($number_of_products / 2)) {
echo ' <tr bgcolor="#ffffff">' . "\n";
} else {
echo ' <tr bgcolor="#f4f7fd">' . "\n";
}
echo ' <td nowrap><font face="' . SMALL_TEXT_FONT_FACE . '" size="' . SMALL_TEXT_FONT_SIZE . '" color="' . SMALL_TEXT_FONT_COLOR . '"> <a href=http://www.phpbuilder.com/board/archive/index.php/"' . tep_href_link(FILENAME_PRODUCT_INFO, 'category_id=' . $HTTP_GET_VARS['category_id'] . '&index_id=' . $HTTP_GET_VARS['index_id'] . '&subcategory_id=' . $HTTP_GET_VARS['subcategory_id'] . '&products_id=' . $listing_values['products_id'], 'NONSSL') . '">';
$products_name = tep_products_name($listing_values['manufacturers_location'], $listing_values['manufacturers_name'], $listing_values['products_name']);
echo $products_name . '</a> </font></td>' . "\n";
$check_special = tep_db_query("select specials.specials_new_products_price from specials where products_id = '" . $listing_values['products_id'] . "'");
if (tep_db_num_rows($check_special)) {
$check_special_values = tep_db_fetch_array($check_special);
$new_price = $check_special_values['specials_new_products_price'];
}
echo ' <td align="right" nowrap><font face="' . SMALL_TEXT_FONT_FACE . '" size="' . SMALL_TEXT_FONT_SIZE . '" color="' . SMALL_TEXT_FONT_COLOR . '"> ';
if ($new_price) {
echo '<s>FL. ' . $listing_values['products_price'] . '</s> <font color="' . SPECIALS_PRICE_COLOR . '">FL. ' . $new_price . '</font>';
unset($new_price);
} else {
echo 'FL. ' . $listing_values['products_price'];
}
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
}
} else {
?>
I'am busy adjusting the script's of theexchangeproject shop for our own shop.
We have a heuge database with products and it's the intention to show them in groups of 10.
The script allows a max result with the search engine but when i set it to ten
it won't display a button with next results.
In subcategories it is even worse there is no max result at all and it wil display everything that is in the subcategorie.
I have put the script parts in here for you to see i'am just starting with php and this is going to far for me.
Search script:
$row = 0;
$search = tep_db_query("select manufacturers.manufacturers_name, manufacturers.manufacturers_location, products.products_id, products.products_name, products.products_price from manufacturers, products_to_manufacturers, products where products_to_manufacturers.products_id = products.products_id and products_to_manufacturers.manufacturers_id = manufacturers.manufacturers_id and (products.products_name like '%" . $HTTP_POST_VARS['query'] . "%' or manufacturers.manufacturers_name like '%" . $HTTP_POST_VARS['query'] . "%') order by products.products_name limit " . MAX_DISPLAY_SEARCH_RESULTS);
while ($search_values = tep_db_fetch_array($search)) {
$row++;
$products_name = tep_products_name($search_values['manufacturers_location'], $search_values['manufacturers_name'], $search_values['products_name']);
if (floor($row/2) == ($row/2)) {
echo ' <tr bgcolor="#ffffff">' . "\n";
} else {
echo ' <tr bgcolor="#f4f7fd">' . "\n";
}
echo ' <td nowrap><font face="' . SMALL_TEXT_FONT_FACE . '" size="' . SMALL_TEXT_FONT_SIZE . '" color="' . SMALL_TEXT_FONT_COLOR . '"> <a href=http://www.phpbuilder.com/board/archive/index.php/"' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $search_values['products_id'], 'NONSSL') . '">' . $products_name . '</a> </font></td>' . "\n";
echo ' <td align="right" nowrap><font face="' . SMALL_TEXT_FONT_FACE . '" size="' . SMALL_TEXT_FONT_SIZE . '" color="' . SMALL_TEXT_FONT_COLOR . '"> FL. ' . $search_values['products_price'] . ' </font></td>' . "\n";
echo ' </tr>' . "\n";
}
?>
Results scripts:
<?
$listby_query = tep_db_query("select sql_select from category_index where category_index_id = '" . $HTTP_GET_VARS['index_id'] . "'");
$listby_values = tep_db_fetch_array($listby_query);
$listby = $listby_values['sql_select'];
// we need to look for the sort location of manufacturers_name<>products_name - this method is not the best but it works for now
$sort_location = tep_db_query("select manufacturers.manufacturers_location from products, manufacturers, products_to_manufacturers, products_to_subcategories where products_to_" . $listby . "." . $listby . "_id = '" . $HTTP_GET_VARS['subcategory_id'] . "' and products_to_subcategories.products_id = products.products_id and products.products_id = products_to_manufacturers.products_id and products_to_manufacturers.manufacturers_id = manufacturers.manufacturers_id order by manufacturers.manufacturers_name, products.products_name");
$sort_location_values = tep_db_fetch_array($sort_location);
if ($sort_location_values['manufacturers_location'] == '0') { // the location of manufacturers name is to the left of the products name
$listing = tep_db_query("select products.products_id, products.products_name, manufacturers.manufacturers_name, manufacturers.manufacturers_location, products.products_price from products, manufacturers, products_to_manufacturers, products_to_subcategories where products_to_" . $listby . "." . $listby . "_id = '" . $HTTP_GET_VARS['subcategory_id'] . "' and products_to_subcategories.products_id = products.products_id and products.products_id = products_to_manufacturers.products_id and products_to_manufacturers.manufacturers_id = manufacturers.manufacturers_id order by manufacturers.manufacturers_name, products.products_name");
} else { // its to the right..
$listing = tep_db_query("select products.products_id, products.products_name, manufacturers.manufacturers_name, manufacturers.manufacturers_location, products.products_price from products, manufacturers, products_to_manufacturers, products_to_subcategories where products_to_" . $listby . "." . $listby . "_id = '" . $HTTP_GET_VARS['subcategory_id'] . "' and products_to_subcategories.products_id = products.products_id and products.products_id = products_to_manufacturers.products_id and products_to_manufacturers.manufacturers_id = manufacturers.manufacturers_id order by products.products_name, manufacturers.manufacturers_name");
}
tep_db_free_result($sort_location); // lets free the result from memory..
$number_of_products = '0';
if (tep_db_num_rows($listing)) {
while ($listing_values = tep_db_fetch_array($listing)) {
$number_of_products++;
if (($number_of_products / 2) == floor($number_of_products / 2)) {
echo ' <tr bgcolor="#ffffff">' . "\n";
} else {
echo ' <tr bgcolor="#f4f7fd">' . "\n";
}
echo ' <td nowrap><font face="' . SMALL_TEXT_FONT_FACE . '" size="' . SMALL_TEXT_FONT_SIZE . '" color="' . SMALL_TEXT_FONT_COLOR . '"> <a href=http://www.phpbuilder.com/board/archive/index.php/"' . tep_href_link(FILENAME_PRODUCT_INFO, 'category_id=' . $HTTP_GET_VARS['category_id'] . '&index_id=' . $HTTP_GET_VARS['index_id'] . '&subcategory_id=' . $HTTP_GET_VARS['subcategory_id'] . '&products_id=' . $listing_values['products_id'], 'NONSSL') . '">';
$products_name = tep_products_name($listing_values['manufacturers_location'], $listing_values['manufacturers_name'], $listing_values['products_name']);
echo $products_name . '</a> </font></td>' . "\n";
$check_special = tep_db_query("select specials.specials_new_products_price from specials where products_id = '" . $listing_values['products_id'] . "'");
if (tep_db_num_rows($check_special)) {
$check_special_values = tep_db_fetch_array($check_special);
$new_price = $check_special_values['specials_new_products_price'];
}
echo ' <td align="right" nowrap><font face="' . SMALL_TEXT_FONT_FACE . '" size="' . SMALL_TEXT_FONT_SIZE . '" color="' . SMALL_TEXT_FONT_COLOR . '"> ';
if ($new_price) {
echo '<s>FL. ' . $listing_values['products_price'] . '</s> <font color="' . SPECIALS_PRICE_COLOR . '">FL. ' . $new_price . '</font>';
unset($new_price);
} else {
echo 'FL. ' . $listing_values['products_price'];
}
echo ' </font></td>' . "\n";
echo ' </tr>' . "\n";
}
} else {
?>