Results 1 to 8 of 8

Thread: [UnResolved]CheckBox array Problem

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    Resolved [UnResolved]CheckBox array Problem

    this script is a modification of a solution i was given for a similiar problem
    http://vbforums.com/showpost.php?p=2323616&postcount=7

    What im trying to do now... is list a table. The table is full of Links and menu's.

    This is how im trying to have it outputted.

    Navigation minRank: 0
    Home minRank: 0
    Members minRank: 0
    Console minRank: 1
    Forums minRank: 0
    Downloads minRank: 1
    All minRank: 1
    Images minRank: 1
    Exe minRank: 2
    Zip minRank: 1

    This is the script as it is currently. This is also confusing the ***** outa me and i dont know why.

    PHP Code:
    $sql "SELECT * FROM navigation_links WHERE menu_id = -1";
    $result mysql_query($sql) or die(mysql_error());
    $menus = array();

        while(
    $row mysql_fetch_array($result)) {
              
    $menus[] = $row;
        }
    //Tryed this to see if it'd work.
        
    foreach($menus as $menu){
            
    $sql1 "SELECT * FROM navigation_links  WHERE menu_id = '".$menu['link_id']."'";

             
    $result mysql_query($sql1) or die(mysql_error());
            
    $links = array();
            while(
    $row1 mysql_fetch_array($result)) {
              
    $links[$row1['menu_id']][] = array('id' => $row1['link_id'], 
                                                
    'name' => $row1['link_name'], 
                                              
    'url' => $row1['link_url'], 
                                              
    'minRank' => $row1['minRank']);
      
              }
          }

        foreach(
    $menus as $menu) { 
            echo
    '
        <div class="forum"> 
          <span class="name"><font color="orange">Menu :'
    $menu['link_name'].'</font></span> 
          <span class="description"> minRank:'
    .$menu['minRank'].'</span><br /> 
          <span class="mods">Menu Links:'
    ;
    //*
        
    foreach($links[$menu['id']] as $link) { 

              echo 
    'Mod:'.$link['link_name'].' : '.$link['link_url']. ' : '.$link['minRank']; 
            }
    //*/ 
        
    echo'</span></div><br />'

        } 
    Also this is my database table:
    PHP Code:
    CREATE TABLE `navigation_links` (
      `
    link_idtinyint(3NOT NULL auto_increment,
      `
    link_urlvarchar(50NOT NULL default '',
      `
    link_namevarchar(50NOT NULL default '',
      `
    menu_idtinyint(21NOT NULL default '0',
      `
    minRankint(11NOT NULL default '0',
      `
    disabledint(11NOT NULL default '0',
      
    PRIMARY KEY  (`link_id`)
    TYPE=MyISAM AUTO_INCREMENT=34 
    The problems i had... Were either all links and nav's would show.Or just nav's would show. Depending on what i changed in the query.

    Help is much needed and apperciated.

    EDIT:: RESOLVED

    Solution::

    PHP Code:
    $sql = 'SELECT * FROM navigation_links WHERE menu_id= -1';
    $result = mysql_query($sql) or die(mysql_error());
    $forums = array();
    while($row = mysql_fetch_array($result)) {
      $forums[] = $row;
    }
         
             $sql1 = "SELECT nav.*, nav2.* FROM navigation_links nav JOIN navigation_links nav2 ON nav2.menu_id = nav.link_id";

     $result = mysql_query($sql1) or die(mysql_error());
    $moderators = array();
    while($row1 = mysql_fetch_array($result)) {
      $moderators[$row1['menu_id']][] = array('url' => $row1['link_url'], 'name' => $row1['link_name']);
      
      }
      
    foreach($forums as $forum) { 
    ?> 
    <div class="forum"> 
      <span class="name"><?php echo $forum['link_name']; ?></span> 
      <span class="description"><?php echo $forum['link_url']; ?></span> 
      <span class="mods">Moderators: 
      <?php 
        
    foreach($moderators[$forum['link_id']] as $mod) { 
          
    ?> 
          <a href="userinfo.php?id=<?php echo $mod['url']; ?>"><?php echo $mod['name']; ?></a> 
          <?php 
        

      
    ?></span> 
    <?
    }
    it was this query that made it happen.
    PHP Code:
             $sql1 "SELECT nav.*, nav2.* FROM navigation_links nav JOIN navigation_links nav2 ON nav2.menu_id = nav.link_id"

    Check That...maybe NOt.
    Last edited by PlaGuE; Jun 8th, 2006 at 10:12 PM.
    Without balance, there could only be chaos.
    Without chaos, there could be no balance.
    I live with karma. Eat with destiny. Dream of life without shackles....
    Yet. If life had no consequences, life could not exist, nor could it flourish.


    If at first you dont succeed.You're screwed.

    C++/Java NOOB.

    I aint a professional at PHP, but if i can help i will.

Posting Permissions

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



Click Here to Expand Forum to Full Width