Click here to Skip to main content
14,734,319 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello

I have a site that have a long list of categories..Looking for a code that can show only half of the categories with a "view more"(view more categories button).
Posted

1 solution

How about something like this?

$basic_attributes = array( ... );
    foreach ($basic_attributes as $basic_attribute)
    {
        // Print html for $basic_attribute
    }

    echo ' <form method="post" action="theform.php">';
    if (isset($_POST[i18n('strShowAdvancedAttrButton')]))
    {
        // If showing then hide, but if hidden then show
        $show_table = !$_POST[i18n('strShowAdvancedAttr')];
    }
    else
    {
        // If not set then show
        $show_table = TRUE;
    }
    echo '  <input type="hidden" name="strShowAdvancedAttr" value="' . $show_table . '"/>';
    echo '  <input type="submit" name="strShowAdvancedAttrButton" value="Advanced Attributes"/>';
    echo '</form>';

    // Only show advanced attributes option if selected
    if (isset($_POST['ShowAdvancedAttrButton')]))
    {
    // If advanced attrs are already shown then clicking button hides them again
        if (isset($_POST[i18n('strShowAdvancedAttr')]) && $_POST[i18n('strShowAdvancedAttr')] == TRUE)
        {
            $advanced_attributes = array( ... );
            foreach ($advanced_attributes as $advanced_attribute)
            {
                // Print html for $advanced_attribute
            }
        }
    }
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900