www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Grouping Dynamic Data

  1. #1
    Join Date
    Dec 2011
    Posts
    154

    resolved [RESOLVED] Grouping Dynamic Data

    I have had my admin page going quiet well until I was told to add something, a store.

    Now I have to redo my admin directory a little, I need to make groupings of categories.

    This is what I used to have...
    HTML Code:
    <h2 class="catDir">Website Tools</h2>
            <ul class="catList">
              <?php do {?>
            <li>
              <a href="<?php echo $row_adminCategories['thumbnail']; ?>.php" class="itemLink"><div onMouseOver="$(this).css('background-color', '#03F');" onMouseOut="$(this).css('background-color', '');" class="adminItem"><img src="_images/admin/thumb/cat-<?php echo $row_adminCategories['thumbnail']; ?>.png" alt="<?php echo $row_adminCategories['thumbnail']; ?>" class="adminItemImg">
                <h3><?php echo $row_adminCategories['title']; ?></h3>
              </div>
              </a>
            </li>
              <?php } while ($row_adminCategories = mysql_fetch_assoc($adminCategories)); ?>
            </ul>
    And this is what I have now...
    HTML Code:
    <div id="adminCat">
            <h2 class="logout"><a href="logout.php">Logout</a></h2>
            <h1 class="adminDir">Administrative Directory</h1>
            <h2 class="catDir">Global Tools</h2>
            <ul class="catList">
              <?php do if ($row_adminCategories['group'] == "global"){?>
            <li>
              <a href="<?php echo $row_adminCategories['thumbnail']; ?>.php" class="itemLink"><div onMouseOver="$(this).css('background-color', '#03F');" onMouseOut="$(this).css('background-color', '');" class="adminItem"><img src="_images/admin/thumb/cat-<?php echo $row_adminCategories['thumbnail']; ?>.png" alt="<?php echo $row_adminCategories['thumbnail']; ?>" class="adminItemImg">
                <h3><?php echo $row_adminCategories['title']; ?></h3>
              </div>
              </a>
            </li>
              <?php } while ($row_adminCategories = mysql_fetch_assoc($adminCategories)); ?>
            </ul>
            <p class="clearBoth">&nbsp;</p>
            <h2 class="catDir">Website Tools</h2>
            <ul class="catList">
              <?php do if ($row_adminCategories['group'] == "general"){?>
            <li>
              <a href="<?php echo $row_adminCategories['thumbnail']; ?>.php" class="itemLink"><div onMouseOver="$(this).css('background-color', '#03F');" onMouseOut="$(this).css('background-color', '');" class="adminItem"><img src="_images/admin/thumb/cat-<?php echo $row_adminCategories['thumbnail']; ?>.png" alt="<?php echo $row_adminCategories['thumbnail']; ?>" class="adminItemImg">
                <h3><?php echo $row_adminCategories['title']; ?></h3>
              </div>
              </a>
            </li>
              <?php } while ($row_adminCategories = mysql_fetch_assoc($adminCategories)); ?>
            </ul>
            <p class="clearBoth">&nbsp;</p>
            <h2 class="catDir">Store Tools</h2>
            <ul class="catList">
              <?php do if ($row_adminCategories['group'] == "store"){?>
            <li>
              <a href="<?php echo $row_adminCategories['thumbnail']; ?>.php" class="itemLink"><div onMouseOver="$(this).css('background-color', '#03F');" onMouseOut="$(this).css('background-color', '');" class="adminItem"><img src="_images/admin/thumb/cat-<?php echo $row_adminCategories['thumbnail']; ?>.png" alt="<?php echo $row_adminCategories['thumbnail']; ?>" class="adminItemImg">
                <h3><?php echo $row_adminCategories['title']; ?></h3>
              </div>
              </a>
            </li>
              <?php } while ($row_adminCategories = mysql_fetch_assoc($adminCategories)); ?>
            </ul>
          </div>
    The problem is only the first grouping will show categories, the rest will be blank (nothing there).

    Can someone help me figure out what I did wrong, here.

  2. #2
    Join Date
    Dec 2011
    Posts
    154
    Not to forget this bit of code at the end...
    HTML Code:
    <?php
    mysql_free_result($adminCategories);
    ?>

  3. #3
    Join Date
    Dec 2011
    Posts
    154
    OK, I got it working now, so I added the statement
    HTML Code:
    mysql_data_seek($adminCategories,0);
    after each time mysql_fetch_assoc was called, which then resulted in setting the internal data pointer back to zero, or the beginning.

    Thus resulting in this code...
    HTML Code:
    <div id="adminCat">
            <h2 class="logout"><a href="logout.php">Logout</a></h2>
            <h1 class="adminDir">Administrative Directory</h1>
            <h2 class="catDir">Global Tools</h2>
            <ul class="catList">
              <?php do if ($row_adminCategories['group'] == "global"){?>
            <li>
              <a href="<?php echo $row_adminCategories['thumbnail']; ?>.php" class="itemLink"><div onMouseOver="$(this).css('background-color', '#03F');" onMouseOut="$(this).css('background-color', '');" class="adminItem"><img src="_images/admin/thumb/cat-<?php echo $row_adminCategories['thumbnail']; ?>.png" alt="<?php echo $row_adminCategories['thumbnail']; ?>" class="adminItemImg">
                <h3><?php echo $row_adminCategories['title']; ?></h3>
              </div>
              </a>
            </li>
              <?php } while ($row_adminCategories = mysql_fetch_assoc($adminCategories)); 
    mysql_data_seek($adminCategories,0);?>
            </ul>
            <p class="clearBoth">&nbsp;</p>
            <h2 class="catDir">Website Tools</h2>
            <ul class="catList">
              <?php do if ($row_adminCategories['group'] == "general"){?>
            <li>
              <a href="<?php echo $row_adminCategories['thumbnail']; ?>.php" class="itemLink"><div onMouseOver="$(this).css('background-color', '#03F');" onMouseOut="$(this).css('background-color', '');" class="adminItem"><img src="_images/admin/thumb/cat-<?php echo $row_adminCategories['thumbnail']; ?>.png" alt="<?php echo $row_adminCategories['thumbnail']; ?>" class="adminItemImg">
                <h3><?php echo $row_adminCategories['title']; ?></h3>
              </div>
              </a>
            </li>
              <?php } while ($row_adminCategories = mysql_fetch_assoc($adminCategories)); 
    mysql_data_seek($adminCategories,0);?>
            </ul>
            <p class="clearBoth">&nbsp;</p>
            <h2 class="catDir">Store Tools</h2>
            <ul class="catList">
              <?php do if ($row_adminCategories['group'] == "store"){?>
            <li>
              <a href="<?php echo $row_adminCategories['thumbnail']; ?>.php" class="itemLink"><div onMouseOver="$(this).css('background-color', '#03F');" onMouseOut="$(this).css('background-color', '');" class="adminItem"><img src="_images/admin/thumb/cat-<?php echo $row_adminCategories['thumbnail']; ?>.png" alt="<?php echo $row_adminCategories['thumbnail']; ?>" class="adminItemImg">
                <h3><?php echo $row_adminCategories['title']; ?></h3>
              </div>
              </a>
            </li>
              <?php } while ($row_adminCategories = mysql_fetch_assoc($adminCategories)); 
    mysql_data_seek($adminCategories,0);?>
            </ul>
          </div>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles