SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot samohtwerdna's Avatar
    Join Date
    Jul 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with query and loops

    hello all,

    I am having difficulties with my db queries I think.

    I created a top level navigation for the admin back end of my site. It connects to my db and populates the sub level navigation based on the user.
    all this is in mainnav.php which is included in the header of all back end pages.

    Then I have the actual content back end pages - one of which is a control page that allows/disallows user access to pages (same stuff that gets populated in my drop down list)

    Do I need to kill or quit a connection before trying to requery the same stuff??

    I know somethings is amiss because when I
    PHP Code:
    <?php $query_rsSANavBars "SELECT * FROM sanavbars WHERE FlagStatus = 'A' ORDER BY NavBarId";
    $rsSANavBars mysql_query($query_rsSANavBars$connection1) or die(mysql_error());
    $row_rsSANavBars mysql_fetch_assoc($rsSANavBars);
    $totalRows_rsSANavBars mysql_num_rows($rsSANavBars);
    $debug->save("useridcheck",11,"sausersedit",$row_rsSANavBars['NavBarId'],$connection1);

    include(
    'heading.php');

    ?>
    <?php $debug
    ->save("useridcheck",101,"sausersedit",$row_rsSANavBars['NavBarId'],$connection1); ?>
    my debug script returns a value of 116 for the first check inside the first <?php ?> an then a NULL value for the second check

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well, what's going on in heading.php? It seems that $row_rsSANavBars is used in there, and thus cleared at the point when you're trying to reuse it.
    Saul

  3. #3
    SitePoint Zealot samohtwerdna's Avatar
    Join Date
    Jul 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep,

    does that mean that I cannot reuse $row_rsSANavBars ?

    In heading.php I have
    PHP Code:
                $query_rsSANavBars "SELECT * FROM sanavbars WHERE Type = 'SA' AND FlagStatus = 'A' ORDER BY Name";
                
    $rsSANavBars mysql_query($query_rsSANavBars$connection1) or die(mysql_error());
                
    $totalRows_rsSANavBars mysql_num_rows($rsSANavBars); 
    repeated 5 times for each different 'Type' in the sanavbars table

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well, if you reuse the same variable, you will not get back the old content. It doesn't matter if it's include, it works the same if it was single plain file. Simply use different names or use functions.

    I'm not exactly sure what's going on there, but why do you need to repeat same thing 5 times?
    Saul

  5. #5
    SitePoint Zealot samohtwerdna's Avatar
    Join Date
    Jul 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I need the 5 queries because I am changing the class of my top level ul based on the contents of the sublevel ul having a matching link with the current page. So I repeat:

    in heading.php
    Last edited by samohtwerdna; Jul 23, 2007 at 18:38. Reason: code unusable

  6. #6
    SitePoint Zealot samohtwerdna's Avatar
    Join Date
    Jul 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Forget that Last post - you were right I need unique variable names.
    Thanks for the help!


Bookmarks

Posting Permissions

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