need 2 PHP/mySQL modifications working together ...
$30-250 USD
Décerné
Publié il y a presque 12 ans
$30-250 USD
Payé lors de la livraison
I have a line of code and 2 different modifications, by 2 different programmers. What I need done is them both working together correctly. I'm sure that someone with a good understanding of PHP can figure this out quite quickly.
The first modification sorts an array of categories alphabetically, while the second modification shows only categories which have products listed within.
The ORIGINAL code line is:
---------------------------------------------------------------------------------------------------------------------------------------
while ($cat_details = $db->fetch_array($sql_select_categories))
{
$subcat_link = basename($_SERVER['PHP_SELF']) . '?parent_id=' . $cat_details['category_id'] . $additional_vars;
$output .= '<tr> '.
' <td class="contentfont"> » <a href="' . $subcat_link . '">' . $category_lang[$cat_details['category_id']] . '</a></td> '.
'</tr> ';
}
---------------------------------------------------------------------------------------------------------------------------------------
The FIRST MODIFICATION tells me to replace the original code with:
---------------------------------------------------------------------------------------------------------------------------------------
while ($cat_details = $db->fetch_array($sql_select_categories))
{
$cat_array[$cat_details['category_id']]["name"]=$category_lang[$cat_details['category_id']];
}
if(is_array($cat_array)){
asort($cat_array);
foreach($cat_array as $key => $value){
$subcat_link = basename($_SERVER['PHP_SELF']) . '?parent_id=' . $key . $additional_vars;
$output .= '<tr> '.
' <td class="contentfont"> » <a href="' . $subcat_link . '">' . $category_lang[$key] . '</a></td> '.
'</tr> ';
}
}
---------------------------------------------------------------------------------------------------------------------------------------
While the SECOND MODIFICATION tells me to replace the original code with:
---------------------------------------------------------------------------------------------------------------------------------------
if ($cat_counter[$cat_details['category_id']] > 0 || COUNT_CATS == 0)
{
$output .= '<tr> '.
' <td class="contentfont"> » <a href="' . $subcat_link . '">' . $category_lang[$cat_details['category_id']] . '</a> '.
(($cat_counter[$cat_details['category_id']]) ? '<span class="cnt">(' . $cat_counter[$cat_details['category_id']] .')</span>' : '').
' </td> '.
'</tr> ';
}
---------------------------------------------------------------------------------------------------------------------------------------
So again, what I need is BOTH modifications working together as ONE, with both functions working correctly.
I am also attaching a TXT file with the code again in case it doesn't display correctly.