Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: PHP Navigation

  1. #1
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Navigation

    I am trying to make a navigation script that will take me to a page named jobs.php and then on that page display another PHP navigation menu just for that page. I got that much working, but when I click a link on the jobs page, it does not include that page but simply dislpays that pages code. I am using this as my main navigation:
    PHP Code:
    <?php
    switch($_GET["page"]) {

        default: 
    // Initial case
            
    require('cpanel_home.php');
        break;
        
        case 
    "content"// Content case
            
    require('edit_content.php');
        break;
            
        case 
    "jobs"// Jobs case
            
    require('jobs.php');
        break;
        
        case 
    "create_pages"// Create pages case
            
    require('create_pages.php');
        break;
        
        case 
    "statistics"// Statistics case
            
    require('statistics.php');
        break;
        
        case 
    "themes"// Themes case
            
    require('themes.php');
        break;
        
        case 
    "mail"// Mail case
            
    require('mail.php');
        break;
        
    }
    ?>
    And this as my job navigation:
    PHP Code:
    <?php
    switch($_GET["action"]) {

        default: 
    //Original case
            
    require('job_manager/default.php');
        break;
        
        
        case 
    "search"//Search case
            
    require('job_manager/search.php');
        break;
        
        
        case 
    "add"//Add case
            
    require('job_manager/add.php');
        break;
        
        
        case 
    "update"//Update case
            
    require('job_manager/update.php');
        break;
        
        
        case 
    "view_all"//View all case
            
    require('job_manager/view_all.php');
        break;
        
        
        case 
    "delete"//Delete case
            
    require('job_manager/delete.php');
        break;
        
    }
    ?>
    The code for the jobs page is:
    PHP Code:
    <ul>
        <li><a href="jobs.php">Main</a></li>
        <li><a href="jobs.php?action=search">Search Jobs</a></li>
        <li><a href="jobs.php?action=add">Add Job</a></li>
        <li><a href="jobs.php?action=update">Update Jobs</a></li>
        <li><a href="jobs.php?action=view_all">View All</a></li>
        <li><a href="jobs.php?action=delete">Delete Jobs</a></li>
    </ul>

        <?php
            
    require('job_nav.php');
        
    ?>

    </body>
    </html>
    Is there a reason that it does not simply include the page in my code, but rather takes me to that page?

  2. #2
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Anyone have an idea?

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Please link as I am not sure what you mean.

    The code looks fine to me, though.

    require just takes ALL of the html and puts that into your page. Perhaps you need to make those other pages not full html documents, but rather, chunks, like removing the <html><body>.... tags, etc.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The link to where I get this "error" is http://www.echo-designes.com/testing....php?page=jobs . If you click on one of the links on that page, it opens that page, instead of including it. Hope this will help you find a solution

  5. #5
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    at first glance, there seems to be sumthin wrong in ur phpfiles.
    Code:
    Fatal error: Call to undefined function: clean() in /home/bntqann/public_html/testing/cms/job_manager/search.php on line 9
    well I might just be stating the obvious.
    Code:
    Warning: mysql_query(): Access denied for user 'nobody'@'localhost' (using password: NO) in /home/bntqann/public_html/testing/cms/job_manager/view_all.php on line 2
    
    Warning: mysql_query(): A link to the server could not be established in /home/bntqann/public_html/testing/cms/job_manager/view_all.php on line 2
    
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bntqann/public_html/testing/cms/job_manager/view_all.php on line 3
    my conclusion: i dont know anything about php

    sry man. hope sum1 else figures it out

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You do realize the difference between including and going to, correct?
    There is no forwarding enabled there. It seems to just be including the code onto your page, which, effectively, is just displaying the other page.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    You do realize the difference between including and going to, correct?
    There is no forwarding enabled there. It seems to just be including the code onto your page, which, effectively, is just displaying the other page.
    Yeah, I want it to include the other page in the code of the page that is currently being displayed. Is there a way that I can make it do so?

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It should be.

    Hmm.... have you looked at the source code to see if it's outputting the 'right' html, but then the html isn't displaying how you want?


    EDIT: Ok, I get it.

    Your PHP isn't in the right spot.

    You need to place your PHP within the html, so it outputs the html of the other page at the right point.

    If you look at the source, you'll see the source of the required/included page, then, following that, the source of the main page.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #9
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It is outputting the html that I want it to, but it is not including it in the page, but rather just displaying that code.

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Yes, exactly.

    include() and require() do exactly this:
    they take all of the html from a document AS-IS, then place that html into the html of your current document at the point at which they are called.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •