![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 | ||
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,111
|
![]() So I have this page https://publisherbucks.com/test/
If you check the NonFiction expandable menu, it works perfectly. However, the other 5 top tier categories on the page do not, they show the top tier category as an expandable option below its top tier. They are all included in the same SQL table with a data setup like this: Quote:
Quote:
This is confusing the fuck out me. To clarify, I have checked the SQL data structure and it is standardized throughout, so its *not* a data structure issue in SQL.
__________________
NOTHING TO SEE HERE |
||
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,111
|
Resolved this finally, it seems there was a hidden blank space in the SQL table data which was fucking things up
![]()
__________________
NOTHING TO SEE HERE |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
this & that
Industry Role:
Join Date: May 2005
Location: Beer City
Posts: 5,300
|
All im seeing is: Oh snap... Looks like another COVID-19 conspiracy took down this page... New World Order and Illuminati are real yo LOL
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,111
|
Probably something to do with Huggles...
__________________
NOTHING TO SEE HERE |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,212
|
cleaned it up a bit
Code:
<?php // Database connection settings $host = "localhost"; $username = "Username"; $password = "Password"; $dbname = "DB"; // Create connection $conn = new mysqli($host, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Fetch categories from the BISAC table, ordered alphabetically $sql = "SELECT ID, Code, Category, Comments FROM BISAC ORDER BY Category"; $result = $conn->query($sql); if (!$result) { die("Query failed: " . $conn->error); } $categories = $result->fetch_all(MYSQLI_ASSOC); // Close connection $conn->close(); // Define the six main sections $mainSections = [ "Fiction", "NonFiction", "Juvenile Fiction", "Juvenile NonFiction", "Young Adult Fiction", "Young Adult NonFiction" ]; // Function to determine the section (Fiction, NonFiction, etc.) function getMainSection(string $category): string { global $mainSections; foreach ($mainSections as $section) { if (stripos($category, $section . " >") === 0) { return $section; } } return "NonFiction"; // Default to NonFiction if not categorized } // Function to build category tree function buildCategoryTree(array $categories): array { global $mainSections; $trees = array_fill_keys($mainSections, []); foreach ($categories as $item) { $mainSection = getMainSection($item['Category']); $categoryPath = explode(' > ', $item['Category']); $firstCategory = array_shift($categoryPath); // Ensure only top-level categories are stored correctly if (!isset($trees[$mainSection][$firstCategory])) { $trees[$mainSection][$firstCategory] = [ 'subcategories' => [], 'id' => md5($mainSection . ' > ' . $firstCategory) ]; } // Process only immediate subcategories and prevent recursion if (!empty($categoryPath)) { $subCategory = array_shift($categoryPath); if ($subCategory !== $mainSection && $subCategory !== $firstCategory) { if (!isset($trees[$mainSection][$firstCategory]['subcategories'][$subCategory])) { $trees[$mainSection][$firstCategory]['subcategories'][$subCategory] = [ 'subcategories' => [], 'id' => md5($mainSection . ' > ' . $firstCategory . ' > ' . $subCategory) ]; } } } } return $trees; } // Generate categorized trees $categoryTree = buildCategoryTree($categories); // Function to render categories function renderCategories(array $tree): void { if (!empty($tree)) { echo '<ul>'; foreach ($tree as $category => $data) { $hasSubcategories = !empty($data['subcategories']); $uniqueId = $data['id']; echo '<li>'; if ($hasSubcategories) { echo '<input type="checkbox" id="toggle-' . $uniqueId . '" class="toggle">'; echo '<label for="toggle-' . $uniqueId . '" class="category-label">' . htmlspecialchars($category) . ' <span class="expand-icon"></span></label>'; echo '<ul class="subcategories">'; foreach ($data['subcategories'] as $sub => $subData) { echo '<li>' . htmlspecialchars($sub) . '</li>'; } echo '</ul>'; } else { echo htmlspecialchars($category); } echo '</li>'; } echo '</ul>'; } } ?> <!DOCTYPE html> <html lang="en"> <head> <base href="https://gfy.com/" /><!--[if IE]></base><![endif]--> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Categorized BISAC Dropdown</title> <style> .dropdown-container { width: 400px; border: 1px solid #ccc; padding: 10px; max-height: 500px; overflow-y: auto; } ul { list-style: none; padding-left: 0; } li { margin: 5px 0; position: relative; } .category-label { font-weight: bold; cursor: pointer; display: flex; justify-content: space-between; width: 100%; } .expand-icon { font-weight: bold; cursor: pointer; margin-left: 10px; } .toggle { display: none; } .toggle + .category-label + .subcategories { display: none; } .toggle:checked + .category-label + .subcategories { display: block; } .toggle + .category-label .expand-icon::before { content: " (+)"; } .toggle:checked + .category-label .expand-icon::before { content: " (-)"; } </style> </head> <body> <div class="dropdown-container"> <ul> <?php foreach ($mainSections as $mainSection): ?> <li> <input type="checkbox" id="toggle-<?php echo md5($mainSection); ?>" class="toggle"> <label for="toggle-<?php echo md5($mainSection); ?>" class="category-label"><?php echo htmlspecialchars($mainSection); ?> <span class="expand-icon"></span></label> <?php if (!empty($categoryTree[$mainSection])): ?> <ul class="subcategories"> <?php renderCategories($categoryTree[$mainSection]); ?> </ul> <?php endif; ?> </li> <?php endforeach; ?> </ul> </div> </body> </html>
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence. ![]() WP Stuff |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 | |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,111
|
Quote:
![]() Appreciate the assistance though ![]()
__________________
NOTHING TO SEE HERE |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Administrator
Industry Role:
Join Date: Nov 2001
Location: https://gfy.dev
Posts: 187
|
That code looks like it's from 2004.
__________________
Stay up to date - https://gfy.com |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 | |
Confirmed User
Join Date: Jun 2003
Posts: 3,276
|
it's cause it is:
Quote:
![]()
__________________
dead. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() ![]() |
|||||||
|
|||||||
Bookmarks |