Advanced Search

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

Thread: Lets work again! Forum question

  1. #1
    Join Date
    Aug 2009
    Posts
    398
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default Lets work again! Forum question

    Hi again,
    i have file index.php with link <a href='forum.php';>Electronics<a/>
    when i push this link i want to get info about electronics, but how i can say to mysql, that i need only electronics variable, and that will be by only pushing this link??

    ASK if more details needed... Thx
    Last edited by auriaks; 11-10-2009 at 05:02 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,158
    Thanks
    28
    Thanked 623 Times in 619 Posts
    Blog Entries
    1

    Default

    I don't understand your question. Can you try to explain it a bit better? Here are a few questions:

    - Do you already have a page about the electronics?
    - Is it a special category inside your forums?
    - What forums are you using (or is this a a fill out forum, such as a contact forum?)
    - Can you provide a link to your page?

    Thank you!
    Jeremy | jfein.net

  3. #3
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Your link shouldnt have a semi colon.
    <a href='forum.php'>Electronics<a/>
    Not: <a href='forum.php';>Electronics<a/>

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by bluewalrus View Post
    Your link shouldnt have a semi colon.
    <a href='forum.php'>Electronics<a/>
    Not: <a href='forum.php';>Electronics<a/>
    That is part of the answer, however that will just link them to the forum.php file.


    @auriaks

    In addition to the modification above, you would need to pass a variable to that file that will indicate PHP to add on a filter when performing the MySQL look-up.

  5. #5
    Join Date
    Aug 2009
    Posts
    398
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    I dont have this page, because i want to use one forum.php page to show ALL the titles and messages which are choosed by pushing link in index.php. Link {which is in index.php} says what variable to ASK IN forum.php

    like my link is ELECTRONIC, i push on it, and in forum.php, script takes your pushed link and regonises it as electronic variable which is needed. Messy ye?

    I know that is possible to do something like:
    http://www.tester.xz.lt/forum.php?el...,blablablacode
    and something like that saves electronics name and uses it in forum.php as show key.
    Last edited by auriaks; 11-09-2009 at 02:18 PM.

  6. #6
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Okay, so you can do this.


    Change your links to be this format
    <a href='forum.php?&amp;cat=electronics'>Electronics<a/>


    At the start of your page put this in
    PHP Code:
    $url $_SERVER['REQUEST_URI'];
    //from the address get the categorey
    //Not sure how $url will be if it will have the and symbol or the &amp; 
    echo $url;
    // so by result of this echo if it is &amp; change the & below to that
    $page explode ("forum.php?&cat="$url);
    $cat $page[1]; 
    Then use the variable $cat in your sql statment to get the results you want displayed.
    You might want to initialize $cat as something or use an if statment around your sql so it isn't triggered when $ is empty or not set.

  7. #7
    Join Date
    Jul 2009
    Location
    Coquitlam BC Canada
    Posts
    46
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    Like Nile said. Pass info with $_GET.

  8. #8
    Join Date
    Jan 2008
    Posts
    4,158
    Thanks
    28
    Thanked 623 Times in 619 Posts
    Blog Entries
    1

    Default

    Fg:
    I don't recall?

    Bluewalrus:
    Use $_GET, like fg123 said.

    Fg:
    I reversed your post.
    Jeremy | jfein.net

  9. #9
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    How do you use $_GET without knowing the name of the variable passing the value in? I've only used it with a post but thought it would be the same except for different method from the form. $_POST['name'];

  10. #10
    Join Date
    Jan 2008
    Posts
    4,158
    Thanks
    28
    Thanked 623 Times in 619 Posts
    Blog Entries
    1

    Default

    Ok, take your code:
    PHP Code:
    $url $_SERVER['REQUEST_URI'];
    //from the address get the categorey
    //Not sure how $url will be if it will have the and symbol or the &amp; 
    echo $url;
    // so by result of this echo if it is &amp; change the & below to that
    $page explode ("forum.php?&cat="$url);
    $cat $page[1]; 
    And add return $cat at the bottom.
    If the url was form.php?&cat=bob, out return value would be "bob." BUT if you were to go to forum.php?&cat=bob&page=4 it would return "bob&page=4". Using $_GET['cat'] would be more effecient, and only return 'bob' no matter what. (And you do not need the & after the question mark, fyi. )
    Jeremy | jfein.net

  11. The Following User Says Thank You to Nile For This Useful Post:

    bluewalrus (11-10-2009)

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
  •