Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default PHP Image Variable.

    I have a variable stored in a database, which is a number up to three characters long (I.e 234)

    I wish to display an image called the same as the number in the database, which obviously varies per account.

    How can I get it to display something like www.site.com/234.png on the page? www.site.com/number.png?

    Sorry if it doesn't make sense.

    Jack.

  2. #2
    Join Date
    Aug 2010
    Location
    London
    Posts
    312
    Tokens
    359
    Habbo
    Fraged

    Default

    Quote Originally Posted by Jack! View Post
    I have a variable stored in a database, which is a number up to three characters long (I.e 234)

    I wish to display an image called the same as the number in the database, which obviously varies per account.

    How can I get it to display something like www.site.com/234.png on the page? www.site.com/number.png?

    Sorry if it doesn't make sense.

    Jack.
    <?php
    $sql = "SELECT your_image FROM your_table WHERE your_conditions_here";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_assoc($result)) {
    ?>
    <img src="<?php echo $row['your_image']; ?>" />
    <?php
    } ?>

    something like that?

  3. #3
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    Quote Originally Posted by Huggies View Post
    <?php
    $sql = "SELECT your_image FROM your_table WHERE your_conditions_here";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_assoc($result)) {
    ?>
    <img src="<?php echo $row['your_image']; ?>" />
    <?php
    } ?>

    something like that?
    <img src="/images/skins/<?php echo $row['your_image']; ?>.png" />

    Would that work?

  4. #4
    Join Date
    Aug 2010
    Location
    London
    Posts
    312
    Tokens
    359
    Habbo
    Fraged

    Default

    Quote Originally Posted by Jack! View Post
    <img src="/images/skins/<?php echo $row['your_image']; ?>.png" />

    Would that work?
    I think it should, sorry I can't help you out alot, I'm fairly new to PHP. Let me know if it does work though!

  5. #5
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    Quote Originally Posted by Huggies View Post
    I think it should, sorry I can't help you out alot, I'm fairly new to PHP. Let me know if it does work though!
    Didn't work, haha.

  6. #6
    Join Date
    Oct 2011
    Location
    Melbourne
    Posts
    637
    Tokens
    1,376

    Default

    You need to get $row from a query from the database. So you perform your query, then I do a number rows to see if it exists (returns 1 - not sure if needed), then do the $rows = mysql_fetch_array.
    Jacks method looks okay.

  7. #7
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    Quote Originally Posted by Blinger View Post
    You need to get $row from a query from the database. So you perform your query, then I do a number rows to see if it exists (returns 1 - not sure if needed), then do the $rows = mysql_fetch_array.
    Jacks method looks okay.
    Well what I currently have is a config file that grabs the data from the database and stores it in a session which all works fine, what I was trying is:

    <img src="/images/skins/<?php echo $_SESSION['skin']; ?>.png" />

    Is what I was trying but no luck, should that work?

  8. #8
    Join Date
    Oct 2011
    Location
    Melbourne
    Posts
    637
    Tokens
    1,376

    Default

    Quote Originally Posted by Jack! View Post
    Well what I currently have is a config file that grabs the data from the database and stores it in a session which all works fine, what I was trying is:

    <img src="/images/skins/<?php echo $_SESSION['skin']; ?>.png" />

    Is what I was trying but no luck, should that work?
    post your config file.

  9. #9
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    Quote Originally Posted by Blinger View Post
    post your config file.
    Config file works fine as I have other sessions stored that gather the information and display it elsewhere on the system fine.

  10. #10
    Join Date
    Oct 2011
    Location
    Melbourne
    Posts
    637
    Tokens
    1,376

    Default

    Quote Originally Posted by Jack! View Post
    Config file works fine as I have other sessions stored that gather the information and display it elsewhere on the system fine.
    It's hard to say if your script should work or not without seeing it. Post that snippet of code then.

Page 1 of 2 12 LastLast

Posting Permissions

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