Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    changing id with php ???

    hello. I want to know if it's possible to take an included file and change some lines when echo-ing?

    For example, if my code is like this:

    Code:
    <ul id="primary-nav">
      <li><a href="#">123</a></li>
      <li class="menuparent"><a href="#">456</a>
      <ul>
    	  <li><a href="#">789</a></li>
    </ul>
    </ul>
    Can I change the first line to this:

    <ul id="secondary-nav">
    ???

  • #2
    Regular Coder
    Join Date
    Aug 2006
    Location
    UK, London, Dartford
    Posts
    221
    Thanks
    3
    Thanked 14 Times in 14 Posts
    Can you explain more, do you mean hiding and showing layers, or diffrent CSS when it'sclicked?

  • #3
    New Coder
    Join Date
    Jun 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know if it's possible, but I want to include file and then somehow change the first line in it - this would be the first line:

    <ul id="secondary-nav">

    or simply fopen file and maybe somehow delete that line. Is that possible?

  • #4
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What you'd have to do is set a variable and then use that (something like this.
    PHP Code:
    If (this condition) {
      
    $id_name="primay-nav";
    }else{
      
    $id_name="secondary-nav";
    }
    include_once(
    "includes/your_include_name.php"); 
    Code:
    <ul id="<?php echo $id_name; ?>">
      <li><a href="#">123</a></li>
      <li class="menuparent"><a href="#">456</a>
      <ul>
        <li><a href="#">789</a></li>
      </ul>
    </ul>
    Last edited by musher; 09-01-2006 at 07:25 AM.
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #5
    New Coder
    Join Date
    Jun 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Will it work, if I give something like this:
    PHP Code:
    $condition=$POST['$send']; // $send=send_no
    if ($condition="send_yes";) {
      
    $id_name="primay-nav";
    }else{
      
    $id_name="secondary-nav";
    }
    include_once(
    "includes/file.php"); 
    Sorry, that I can't test it myself, I just don't have available server right now.

  • #6
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, that should work

    Quote Originally Posted by keissfootball
    Will it work, if I give something like this:
    PHP Code:
    $condition=$POST['$send']; // $send=send_no
    if ($condition="send_yes";) {
      
    $id_name="primay-nav";
    }else{
      
    $id_name="secondary-nav";
    }
    include_once(
    "includes/file.php"); 
    Sorry, that I can't test it myself, I just don't have available server right now.
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #7
    New Coder
    Join Date
    Jun 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do I have to pass it through post??? Because if I leave the code as is, it displays <ul id="">
    Last edited by keissfootball; 09-01-2006 at 01:35 PM.

  • #8
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, You should have this is your main file
    PHP Code:
    $condition=$_POST['$send']; // $send=send_no
    if ($condition="send_yes";) {
      
    $id_name="primay-nav";
    }else{
      
    $id_name="secondary-nav";
    }
    include_once(
    "includes/file.php"); 
    and this in your include
    PHP Code:
    <ul id="<?php echo $id_name?>">
    Make sure that $_POST['$send'] has something in it i.e. "send_yes " for primay-nav to be true (I would echo it)
    Last edited by musher; 09-02-2006 at 07:56 PM.
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #9
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Don't forget the underscore.

    $_POST["whatever"]

  • #10
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by arnyinc
    Don't forget the underscore.

    $_POST["whatever"]
    Good catch arnyinc.
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #11
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Don't forget to use the "is this equal to this" rather than the "set this equal to this" (and get rid of that semicolon):
    PHP Code:
    if ($condition="send_yes";) { //wrong
    if ($condition == "send_yes") { //right 


  •  

    Posting Permissions

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