Моя проблема в том, что я не получал товаров из mysql. Если я повторю запрос sql, я верну 3 строки, и это нормально, потому что у меня есть 3 продукта в категории ID-12.
Если вывести эхо из $ category_id, и я получу: 12
Что не так с моим кодом? Ошибок не было.
Спасибо!
<?php
function render_category_page($category_id)
{
$id = (int)$this->$category_id;
$connect_to_mysql = my_conn();
if($connect_to_mysql == true )
{
get_product_data("SELECT * FROM products WHERE category_id = '".$id."'", $connect_to_mysql, $limit = 0);
if(get_product_data())
{
if(count_rows_of_sql(get_product_data) == 0 )
{
show_message("There are no rows in the table.");
}
else
{
show_message("There are '".count_rows_of_sql(get_product_data)."' rows in the table.");
$product = fetch_data_from_sql(get_product_data());
$category_id = (int)$product['category_id'];
$product_name = "<h1 class='product_name'>".cut_html_chars($product['product_name'])."</h1>";
$product_desricption = "<p class='product_desricption'>".cut_html_chars($product['product_desricption'])."</p>";
$product_full_content = "<div class='product_full_content'>".cut_html_chars($product['product_full_content'])."</div>";
$product_to_link = "<a href='".$this->$product_to_link."' class='product_to_link' title='".$this->$product_name."' target='_self'>".$this->$product['product_seo_url']."</a>";
for($i = 1; $i <= count_rows_of_sql(get_product_data); $i++)
{
$i++;
}
$products_in_category = (int)products_in_category($i);
}
}
else
{
log_message("The sql command didnt run.", $type = "sql", $write_to_file = 1);
write_error_message_to_file("./logs/error_logs/", $filename = $type . "-error" . date("Y-m-d-H:i:s") . generate_random_number($min = 1, $max = 9999), $fileType = "txt");
}
}
else
{
log_message("Cant connect to database.", $type = "sql", $write_to_file = 1);
write_error_message_to_file("./logs/error_logs/", $filename = $type . "-error" . date("Y-m-d-H:i:s") . generate_random_number($min = 1, $max = 9999), $fileType = "txt");
}
}
render_page($page_type = "category", $html = 1, $template = "bootsrap-4", $pagination = $products_in_category, $product_container_div = "product-container", render_category_page($category_id));
?>