SEO Software
Closed Thread
Results 1 to 7 of 7

Thread: navigation help

  1. #1
    Fulltime Member Devil_Inc will become famous soon enough
    Join Date
    Apr 2006
    Location
    Guyana
    Posts
    762
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default navigation help

    ok here it is, i have 2 bits of code i want to work in conjunction with each other, one being the site navigation code & the code of another script, il go more into detail:

    SITE WIDE CODE:
    PHP Code:
            <?php
    if (isset($_GET['page']) && isset($_GET['id']) && file_exists('mods/'.$_GET[id].'/'.$_GET[page].'.php')) {
    include 
    'mods/'.$_GET[id].'/'.$_GET[page].'.php';
    }
    else {
    include 
    "mods/main.php";
    }
    ?>
    script code:

    PHP Code:
    switch($_GET['action'])
    {

        case 
    "addtutorial":

        if(!isset(
    $_POST['add_tutorial']))
        {
            echo 
    "
            <table border='0' cellpadding='0' cellspacing='0' width='500'>
            <form action='$self?action=addtutorial' method='post'>
                <tr>
                    <td>Name:</td>
                    <td><input type='text' name='name'></td>
                </tr>
                <tr>
                    <td>Title:</td>
                    <td><input type='text' name='title'></td>
                </tr>
                <tr>
                    <td>Category:</td>
                    <td>
                        <select name='category'>
                            "
    ;
                    
    $query mysql_query("SELECT * FROM tutorials_categorys ORDER BY id ASC") or die(mysql_error());
                    while(
    $row mysql_fetch_array($query))
                    {
                        echo 
    "<option value='$row[id]'>$row[category]";
                    }
                            echo 
    "
                        </select>
                    </td>
                </tr>
                    <tr>
                    <td>Tutorial:</td>
                    <td><textarea name='tutorial' cols='40' rows='10'></textarea></td>
                </tr>
                </tr>
                    <tr>
                    <td>Short Description:</td>
                    <td><textarea name='short_description' cols='40' rows='2'></textarea></td>
                </tr>
                <tr>
                    <td>Email:</td>
                    <td><input type='text' name='email' maxlength='50'></td>
                </tr>
                <tr>
                    <td>Show Email?</td>
                    <td><input type='checkbox' name='show_email' value='1' checked></td>
                </tr>
                <tr>
                    <td colspan='2'><center><input type='submit' name='add_tutorial' value='Submit New Tutorial'></center></td>
                </tr>
            </form>
            </table>
            "
    ;
        }
        elseif(isset(
    $_POST['add_tutorial']))
        {
            
    $name mysql_real_escape_string(strip_tags($_POST['name']));
            
    $title mysql_real_escape_string(strip_tags($_POST['title']));
            
    $category mysql_real_escape_string(strip_tags($_POST['category']));
            
    $tutorial mysql_real_escape_string(strip_tags($_POST['tutorial']));
            
    $short_description mysql_real_escape_string(strip_tags($_POST['short_description']));
            
    $email mysql_real_escape_string(strip_tags($_POST['email']));
            
    $show_email mysql_real_escape_string($_POST['show_email']);
            
    $date date("m/d/Y");
            
    $time time();

            
    $error_msg = array();
            if(empty(
    $name))
            {
                
    $error_msg[] = "Please insert a name!<br />";
            }
            if(empty(
    $title))
            {
                
    $error_msg[] = "Please insert a title!<br />";
            }
            if(empty(
    $category))
            {
                
    $error_msg[] = "Please insert a category!<br />";
            }
            if(empty(
    $tutorial))
            {
                
    $error_msg[] = "Please insert the tutorial text!<br />";
            }
            if(empty(
    $short_description))
            {
                
    $error_msg[] = "Please insert a short description!<br />";
            }
            if(empty(
    $email))
            {
                
    $error_msg[] = "Please insert an email!<br />";
            }
            if(
    count($error_msg)>0)
            {
                echo 
    "<strong>ERROR:</strong><br>n";
                foreach(
    $error_msg as $err)
                    echo 
    "$err";
            }
            else
            {
                
    $sql "INSERT INTO tutorials (submitter, text, short_description, title, cat_id, date_submitted, time_submitted, show_email, email, is_validated) VALUES ('$name', '$tutorial', '$short_description', '$title', '$category', '$date', '$time', '$show_email', '$email', '0')";
                
    mysql_query($sql) or die(mysql_error());
                echo 
    "Tutorial added for review!";
            }
        }
        break;

        case 
    "viewcategory":
        if(
    $_GET['id'])
        {

            
    $id = (int)$_GET['id'];
            
    $query mysql_query("SELECT * FROM tutorials WHERE cat_id = '$id' AND is_validated = '1'") or die(mysql_error());

            if(
    mysql_num_rows($query) == 0)
            {
                echo 
    "No tutorials for this category yet!";
            }
            else
            {
                echo 
    "<h1>Tutorials</h1>";
                echo 
    "<table border='0' cellpadding='0' cellspacing='0' width='500'>";
                while(
    $row mysql_fetch_array($query))
                {
                    echo 
    "
                        <tr>
                            <td>Title:</td>
                            <td><b>$row[title]</b></td>
                        </tr>
                        <tr>
                            <td>Date Submitted:</td>
                            <td><b>$row[date_submitted]</b></td>
                        </tr>
                        <tr>
                            <td>Views:</td>
                            <td>$row[views]</td>
                        </tr>
                        <tr>
                            <td>Short Description:</td>
                            <td>$row[short_description]</td>
                        </tr>
                        <tr>
                            <td>Submitter:</td>
                            <td>$row[submitter]</td>
                        </tr>
                        <tr>
                            <td colspan='2'><center><b><a href='$self?action=viewtutorial&id=$row[id]'>View</a></b></center></td>
                        </tr>
                        <tr>
                            <td colspan='2'><hr /></td>
                        </tr>
                    "
    ;
                }
                echo 
    "</table>";
            }
        }
        else
        {
            echo 
    "Please give me a category ID!";
        }
        break;

        case 
    "viewtutorial":

    ETC..... 
    any help guys?
    this is what the url should look like when finished:
    Code:
    ?id=t&page=tutorials&action=viewcategory&id=1
    PM me for both full codes.


  2. SEO Software

  3. #2
    Fulltime Member Zegg90 is on a distinguished road
    Join Date
    Jan 2006
    Location
    Who needs a place to live?
    Posts
    750
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I'm sorry, but you haven't stated a problem, so I dunno how I can help you.

  4. #3
    Fulltime Member Devil_Inc will become famous soon enough
    Join Date
    Apr 2006
    Location
    Guyana
    Posts
    762
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    domain.com?id=t&page=tutorials&action=viewcategory &id=1

    it wont pass in that url, instead it gives me

    domain.com/?action=viewcategory&id=1

    and the page halts

  5. #4
    Fulltime Member Zegg90 is on a distinguished road
    Join Date
    Jan 2006
    Location
    Who needs a place to live?
    Posts
    750
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    well, in the second part of your code it says:
    PHP Code:
    <a href='$self?action=viewtutorial&id=$row[id]'>View</a
    So it links to ?action=viewtutorial&id=1

    If you want to change it to ?id=t&page=tutorials&action=viewcategory&id=1, you've got a problem, because it's got 'id' in that twice :P
    I suppose you're trying to make it into this:
    ?action=viewtutorial&id=1&page=tutorials
    Try replacing the code I posted above into this:

    PHP Code:
    <a href='$self?action=viewtutorial&page=tutorials&id=$row[id]'>View</a

    I'm actually quite confused by all this. You use the words 'tutorial' and 'category' interchangeably, so I'm not sure which one you want to link to. I'm guessing the tutorials.
    Second, I'm not exactly sure how you want the link to look like. In your example you use 'id' twice, and you display the 'page' variable as simply 'tutorials'. But in the first part of the script it uses 'page' as a real variable. If you want it to stay 'tutorials', why not just hard code that? So in my solution, I kept it as 'tutorials'. If you want to use the title of the article, change it to $row[title]

  6. #5
    Fulltime Member Devil_Inc will become famous soon enough
    Join Date
    Apr 2006
    Location
    Guyana
    Posts
    762
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ok i figured it out, i changed the first get id to module & this link worked, just needed a nudge from zegg in the right direction
    PHP Code:
    ?module=t&page=tutorials&action=viewtutorial&id=
    now i have a new question, is their anyway to use php navigation in iframes so as to not stretch the layout if the content is too much so it can use a scroller?

    i tried

    Code:
    <iframe 
    src ="<?php
    if (isset($_GET['page']) && isset($_GET['module']) && file_exists('mods/'.$_GET[module].'/'.$_GET[page].'.php')) {
    include 'mods/'.$_GET[module].'/'.$_GET[page].'.php';
    }
    else {
    include "mods/main.php";
    }
    ?>"
    width="100%">
    </iframe>
    but it didnt work, any ideas?

  7. #6
    Fulltime Member Zegg90 is on a distinguished road
    Join Date
    Jan 2006
    Location
    Who needs a place to live?
    Posts
    750
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    You could include it inside a <div>.
    Then you use CSS to set its overflow property. You should set it to 'auto' so that it will automatically show a scrollbar if the content is too big. Also remember to set the size of the div.

    More about Overflow: http://www.w3schools.com/css/pr_pos_overflow.asp

  8. #7
    Fulltime Member Devil_Inc will become famous soon enough
    Join Date
    Apr 2006
    Location
    Guyana
    Posts
    762
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    dammit ur a genius! thanks

Closed Thread

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