SitePoint Sponsor

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 25 of 56
  1. #1
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Profile script help

    Hey im fairly new to php and i own a rpg site. At the moment im workin on the profiles, but not doin very well. Could you please give me absolutely any help you can to do with profiles, eg. codes and where to put them. That would be greatly appreciated,
    Thanks

  2. #2
    SitePoint Evangelist LemoNade's Avatar
    Join Date
    Aug 2005
    Location
    Southampton, UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you need to provide some more information. What is your current setup, and what have you got so far?

    -Will

  3. #3
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have got my layout for viewuser.php (profile layout), but i dont know the script which shows which user it is and info about that user. All i know is how to get info about the session user.

  4. #4
    SitePoint Evangelist LemoNade's Avatar
    Join Date
    Aug 2005
    Location
    Southampton, UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you using a database of some kind? Do you have a table which holds all the user details, and if so - What are the columns you want outputting?

    -Will

  5. #5
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes i have a db with a users table and im trying to output rank, wealth, online status, quote, etc. i can do that myself it jst i can only do that for the session user. what im tryin to do is output that info for the user of the profile. eg i dont know what $username=...

  6. #6
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the sie is www.tacticalmafia.com if you register and login you will see what i mean. If you click on a username on the main page for example, look where it takes you.

  7. #7
    SitePoint Evangelist LemoNade's Avatar
    Join Date
    Aug 2005
    Location
    Southampton, UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You would probably get all the data from the users table like so:

    PHP Code:
    $sql mysql_query("SELECT * FROM userstable") or die(mysql_error());
    echo (
    "<center>Member Listing</center>");

    while (
    $row mysql_fetch_array($sql)) {

    echo (
    "Username: " $row['username'] . "<br />");
    echo (
    "Rank: " $row['rank'] . "<br />");
    echo (
    "Wealth: " $row['wealth'] . "<br />");
    echo (
    "<br /><br />------------------<br />");

    // End WHILE 
    ...And so on. Try that out (modifying it to suit your script) and see what happens.

    -Will

  8. #8
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok so i put this in viewuser.php with the layout?

  9. #9
    SitePoint Evangelist LemoNade's Avatar
    Join Date
    Aug 2005
    Location
    Southampton, UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah...

  10. #10
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it works! Its basic but i can definately work with this! Thanks very much this is much appreciated!

  11. #11
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you know how i can put this into a table like this one :

    <table cellSpacing=0 cellPadding=2 align=center border=1 width=500 bordercolor=black table bgcolor=#5e5e5e>
    <tr><td align=center background=#a9a9a9
    coolspan=2><font size=1 face=verdana color=#5e5e5e>
    <b><strong>$username Profile</td></tr>
    <tr><td><font size=1 face=verdana><b>Username/b> <a href=sendmsg.php?msg=$username><font color=black>$username</a></td>

    <td align=center width=45% rowspan=12><img src=nopic.jpg height=255 width=255></td></tr>
    <tr><td><font size=1 face=verdana><b>Crew: </b><a href=viewcrew.php?viewcrew=crew><font color=#5e5e5e>
    </a> </td>
    </tr>
    <tr><td><font size=1 face=verdana><b>Rank/b>
    </td>
    </tr>
    <tr><td><font size=1 face=verdana><b>Status/b><font face=verdana size=1>
    </td>

    </tr><tr><td><font size=1 face=verdana><b>Wealth/b>
    </td>
    </tr>

    </table>

  12. #12
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its ok i got it

  13. #13
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im stuck again but this time with a different problem. take a look:

    $money=$row['money'];
    if ("$money" < "5000"){
    $wealth="Empty Pockets";
    }elseif ("$money" = "5001,50000"){
    $wealth="Penny Picker";
    }elseif ("$money" = "50001,250000"){
    $wealth="Spare Change";
    }elseif ("$money" = "250001,1000000"){
    $wealth="Enough";
    }elseif ("$money" = "1000001,5000000"){
    $wealth="Wealthy";
    }elseif ("$money" = "5000001,10000000"){
    $wealth="Rich";
    }elseif ("$money" = "10000001,25000000"){
    $wealth="Richer Than Rich";
    }elseif ("$money" = "25000001,50000000"){
    $wealth="Burning Paper";
    }elseif ("$money" = "50000001,100000000"){
    $wealth="Famous Rich Icon";
    }elseif ("$money" > "100000001"){
    $wealth="Legendary Rich";
    }

    none of the "elseif" work. I am tryin to make it for example "5001 to 50000 = $wealth"

  14. #14
    SitePoint Evangelist LemoNade's Avatar
    Join Date
    Aug 2005
    Location
    Southampton, UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't put variable names (i.e. $wealth) in speech marks. Try this:

    PHP Code:
    $money=$row['money'];
    if (
    $money "5000"){
    $wealth="Empty Pockets";
    }elseif (
    $money "5001,50000"){
    $wealth="Penny Picker";
    }elseif (
    $money "50001,250000"){
    $wealth="Spare Change";
    }elseif (
    $money "250001,1000000"){
    $wealth="Enough";
    }elseif (
    "$money"1000001,5000000"){
    $wealth="Wealthy";
    }elseif (
    $money "5000001,10000000"){
    $wealth="Rich";
    }elseif (
    $money "10000001,25000000"){
    $wealth="Richer Than Rich";
    }elseif (
    "$money"25000001,50000000"){
    $wealth="Burning Paper";
    }elseif (
    $money "50000001,100000000"){
    $wealth="Famous Rich Icon";
    }elseif (
    $money "100000001"){
    $wealth="Legendary Rich";

    Alternatively you could use switch/case to replace all the elseif's, but it'd do the same thing.

    Hope this helps,

    -Will

  15. #15
    SitePoint Enthusiast mike_mech's Avatar
    Join Date
    Nov 2005
    Location
    Poland
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    O man, what an inflexible code.

    Maybe something like this:
    PHP Code:
    <?php

    $intMoney 
    = ( empty( $_GET'money' ] ) ) ? $_GET'money' ];

    $arrTab = array( 'Empty Pockets' => 5000
                     
    'Penny Picker' => 250000
                     
    'Spare Change' => 1000000
                     
    'Enough' => 5000000
                     
    'Wealthy' => 10000000 );

    $strResult 'Empty Pockets';

    foreach( 
    $arrTab as $strKey => $intValue )
    {
        if( 
    $intMoney <= $intValue )
        {
            break;
        }
        
    $strResult $strKey;
    }

    echo 
    $strResult;

    ?>
    This is more flexible, if you want add some code, you have to only modify $arrTab
    Sorry, about my english, it's not my national language :/
    ___
    "Two things are infinite: the universe and human stupidity;
    and I'm not sure about the the universe."
    - Albert Einstein

  16. #16
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it works but no matter on how much money there is it displays "Empty Pockets"

  17. #17
    SitePoint Enthusiast mike_mech's Avatar
    Join Date
    Nov 2005
    Location
    Poland
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TacMaf
    it works but no matter on how much money there is it displays "Empty Pockets"
    Are you sure. I guarantee it works wery well.

    Maybe try replace this:
    PHP Code:
    <?php

    // ...
    $intMoney = ( empty( $_GET'money' ] ) ) ? $_GET'money' ];
    // ...

    ?>
    ... with ...
    PHP Code:
    <?php

    // ...
    $intMoney 1034008// or something else
    // ...

    ?>
    Can you provide the error(s) ?
    Sorry, about my english, it's not my national language :/
    ___
    "Two things are infinite: the universe and human stupidity;
    and I'm not sure about the the universe."
    - Albert Einstein

  18. #18
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that isnt the script i used because i can use the GET function. I connect to the db to get the money. The other script works but only the Empty Pockets displays no matter what amount of money the user has.

  19. #19
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the problem seems to be that the "if" statement works but none of the "elseif" statements work on any of my scripts

  20. #20
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is there an alternative function to if/elseif?

  21. #21
    SitePoint Evangelist LemoNade's Avatar
    Join Date
    Aug 2005
    Location
    Southampton, UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TacMaf
    is there an alternative function to if/elseif?
    Yeah, you can use switch/case as I suggested. You can read up on it
    here.

    -Will

  22. #22
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    still no luck ive tried allsorts now and the same result.

    <?php
    if ($userlevel = "Admin"){
    echo "<font color=blue><b>Admin</b></a>";
    } elseif ($userlevel = "Moderator") {
    echo "<font color=red><b>Mod</b></a>";
    }
    ?>

    thats the script im using. the only problem is it displays "admin" whether the user is mod or not.

  23. #23
    SitePoint Enthusiast mike_mech's Avatar
    Join Date
    Nov 2005
    Location
    Poland
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check the difference between comparison operator and assignment operator

    The assignment operator returns always true. That's why your code displays "admin" in all cases.

    You should write:
    PHP Code:
    <?php
    if ($userlevel == "Admin"){
    echo 
    "<font color=blue><b>Admin</b></a>";
    } elseif (
    $userlevel == "Moderator") {
    echo 
    "<font color=red><b>Mod</b></a>";
    }
    ?>
    Do You see the difference?
    Sorry, about my english, it's not my national language :/
    ___
    "Two things are infinite: the universe and human stupidity;
    and I'm not sure about the the universe."
    - Albert Einstein

  24. #24
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats a very good idea, but now nothing displays

  25. #25
    SitePoint Enthusiast mike_mech's Avatar
    Join Date
    Nov 2005
    Location
    Poland
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    if( $userlevel == 'Admin' )
    {
        echo 
    '<font color=blue><b>Admin</b></a>';

    elseif( 
    $userlevel == 'Moderator' )
    {
        echo 
    '<font color=red><b>Mod</b></a>';
    }
    else
    {
         echo 
    '<font color=red><b>User</b></a>';
    }
    ?>
    Sorry, about my english, it's not my national language :/
    ___
    "Two things are infinite: the universe and human stupidity;
    and I'm not sure about the the universe."
    - Albert Einstein


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
  •