Users rooms.

Jemz

xmas tings.
Aug 6, 2013
166
17
Basically I'm trying to code a small script that posts the rooms the user logged in has made
for example if I was logged in it would post all the rooms I made, I was wondering how would I do this

Code so far:
PHP:
<?php
echo "Habbo rooms: <select name=\"cars\" style=\"color: #7d7d7d;padding: 5px;border-radius: 3px;background: #F1F1F1;border: 1px solid #CCC;border-bottom: 2px solid #CCC;width: 38%;margin-right: 26px;font-weight: bold;\">";
$result = mysql_query("SELECT caption FROM rooms WHERE owner = {username}");
while($row = mysql_fetch_array($result))
echo "<option value='{$row['caption']}'>{$row['caption']}</option>";
echo "</select>";
?>
 

Zaka

Programmer
Feb 9, 2012
471
121
Basically I'm trying to code a small script that posts the rooms the user logged in has made
for example if I was logged in it would post all the rooms I made, I was wondering how would I do this

Code so far:
PHP:
<?php
echo "Habbo rooms: <select name=\"cars\" style=\"color: #7d7d7d;padding: 5px;border-radius: 3px;background: #F1F1F1;border: 1px solid #CCC;border-bottom: 2px solid #CCC;width: 38%;margin-right: 26px;font-weight: bold;\">";
$result = mysql_query("SELECT caption FROM rooms WHERE owner = {username}");
while($row = mysql_fetch_array($result))
echo "<option value='{$row['caption']}'>{$row['caption']}</option>";
echo "</select>";
?>
Indeed it's true that you can write code like this:
PHP:
<?php

if(statement)
echo $var;
else
die();

?>

but thats ONLY when the code is one row, otherwise you gotta open and close it, so for your code to work you should have following code:
PHP:
Habbo rooms: <select name="cars" style="color:#7d7d7d;padding:5px;border-radius:3px;background:#F1F1F1;border:1px solid #CCC;border-bottom:2px solid #CCC;width: 38%;margin-right: 26px;font-weight: bold;">

<?php
    $result = mysql_query("SELECT caption FROM rooms WHERE owner = {username}");

    while($row = mysql_fetch_array($result)) {
        echo "<option value='" .$row['caption']. "'>" .$row['caption']. "</option>";
    }

?>

</select>

This is how I would do it.
 

Jemz

xmas tings.
Aug 6, 2013
166
17
Indeed it's true that you can write code like this:
PHP:
<?php

if(statement)
echo $var;
else
die();

?>

but thats ONLY when the code is one row, otherwise you gotta open and close it, so for your code to work you should have following code:
PHP:
Habbo rooms: <select name="cars" style="color:#7d7d7d;padding:5px;border-radius:3px;background:#F1F1F1;border:1px solid #CCC;border-bottom:2px solid #CCC;width: 38%;margin-right: 26px;font-weight: bold;">

<?php
    $result = mysql_query("SELECT caption FROM rooms WHERE owner = {username}");

    while($row = mysql_fetch_array($result)) {
        echo "<option value='" .$row['caption']. "'>" .$row['caption']. "</option>";
    }

?>

</select>

This is how I would do it.

Thanks but it didn't work still
 

Brad

Well-Known Member
Jun 5, 2012
2,320
993
should work

Code:
<?php   
$getRooms = mysql_query("SELECT `caption`,`description` FROM `rooms` WHERE `owner` = '".filter($_GET['username'])."'");
if (mysql_num_rows($getRooms) == 0) {
    echo 'You do not have any rooms<div class="clear"></div>';
} else {
?><?php
while ($roomData = mysql_fetch_array($getRooms)) {
$roomDescription = null;
if ($roomData['description'] == null)
    $roomDescription = 'No room description!';
else
    $roomDescription = $roomData['description'];
    echo '<tr>
<td valign="top" >
        <div class="room_image">
                <img src="{url}/app/tpl/skins/Habbo/web-gallery/images/myhabbo/rooms/room_icon_open.gif" alt="" align="middle"/>
        </div>
</td>
<td>
            <div class="room_info">
           
                <div class="room_name">
                    '.$roomData['caption'].'
                </div>
                    <img id="room-63773258-report" class="report-button report-r"
                        alt="report"
                        src="{url}/app/tpl/skins/Habbo//web-gallery/images/myhabbo/buttons/report_button.gif"
                        style="display: none;" />
                <div class="clear"></div>
                <div>'.$roomDescription.'
                </div>
                    <!--a href="http://www.habbo.com/client?forwardId=2&amp;roomId=63773258"
                      target="72f577c250db9e5c22a5880ef8cb10f8ad18d7b6"
                      id="room-navigation-link_63773258"
                      onclick="HabboClient.roomForward(this, \'63773258\', \'private\', true); return false;">
                    enter room
                    </a-->
            </div>
           

        <br class=\"clear\" />

</td>
</tr>';
}
?>
</table>
</div>

<?php } ?>
 

Users who are viewing this thread

Top