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 8 of 8
  1. #1
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts

    Php not staying side of DIV

    I am trying to create a profile page which works fine in an all php script. However combining it with html it doesn't work. I attached a screenshot of what it does and the coding.

    http://www.rodgame.org/projects/dmv/profile.php

    PHP Code:
        <div id="page">
            <div id="content">

    <?php

     
    function profile() {
    if(!empty(
    $_SESSION["user_id"])){

     echo 
    "Welcome ".$row['username']." to your profile.";
     }
     }

    ?>

            </div>

            <div style="clear: both;">&nbsp;</div>
        </div>
        <!-- end #page -->
    <div id="footer">
        <p>Copyright (c) 2009 Sitename.com. All rights reserved. Design by Success Web Designs.</p>
    </div>
    Attached Thumbnails Attached Thumbnails Php not staying side of DIV-sss.jpg  
    Last edited by masterofollies; 03-04-2009 at 01:23 AM.

  • #2
    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
    I see that you are defining a function, but I don't see where you're calling that function. The location in the code where you call the function is where the echos are going to dump bytes into the html.

  • #3
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Sorry here is the GET for it.

    PHP Code:
    if (isset($_GET["x"])) {
        
    $x explode(":",$_GET["x"]);

        switch(
    $x[0])
        {
            case 
    'profile':
                
    profile($x[1]);
            break; 

  • #4
    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
    I hope you got my point? You have to call your profile() function at the position where you want the html from the function dumped.

  • Users who have thanked Fumigator for this post:

    masterofollies (03-04-2009)

  • #5
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    I don't quite follow. Do you mean put the GET method in the content area?

  • #6
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    yes, that is what he means.

    Where ever the function profile() is called, that is where the echo is gonna take place

    PHP Code:
        <div id="page"> 
            <div id="content"> 

    <?php 

     
    function profile() { 
    if(!empty(
    $_SESSION["user_id"])){ 

     echo 
    "Welcome ".$row['username']." to your profile."
     } 
     } 

    if (isset(
    $_GET["x"])) { 
        
    $x explode(":",$_GET["x"]); 

        switch(
    $x[0]) 
        { 
            case 
    'profile'
                
    profile($x[1]); 
            break; 
    }
    ?> 

            </div> 

            <div style="clear: both;">&nbsp;</div> 
        </div> 
        <!-- end #page --> 
    <div id="footer"> 
        <p>Copyright (c) 2009 Sitename.com. All rights reserved. Design by Success Web Designs.</p> 
    </div>

  • #7
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Cool it works, thanks

  • #8
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    Ur welcome!


  •  

    Posting Permissions

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