Jump to content

Recommended Posts

What I mean is, I have a custom script for a MUD(Multi-User Dungeon) to add rooms in the 'world', which is this:

 

<?php 
require("sessions.php");
include("connect.php");
include("userinfo.php");

$result = mysql_query("select * from rooms where room='$roomin' order by room"); 
while($row = mysql_fetch_array($result)){
  $roomname=$row['roomname'];
  $roomdesc=$row['roomdesc'];
  $room=$row['room'];
  $north=$row['north'];
  $south=$row['south'];
  $east=$row['east'];
  $west=$row['west'];
  $up=$row['up'];
  $down=$row['down'];
}



//This code runs if the form has been submitted
if (isset($_POST['submit'])) {

//This makes sure they did not leave any fields blank
if (!$_POST['roomname'] | !$_POST['roomdesc'] ) {
die('You did not complete all of the required fields');
}



// now we insert it into the database
mysql_query("UPDATE rooms
SET roomname='".$_POST['roomname']."', roomdesc='".$_POST['roomdesc']."', north='".$_POST['north']."', south='".$_POST['south']."', east='".$_POST['east']."', west='".$_POST['west']."', up='".$_POST['up']."', down='".$_POST['down']."', mnorth='".$_POST['mnorth']."', msouth='".$_POST['msouth']."', meast='".$_POST['meast']."', mwest='".$_POST['mwest']."', mup='".$_POST['mup']."', mdown='".$_POST['mdown']."'
WHERE room='$roomin'") or die(mysql_error());




?>

<title>The Roman Empire</title>
<body bgcolor="grey">
<table width="800"
       border="1"
       cellpadding="0"
       align="center"
       bgColor="CC0000">
<!-- Row 1 -->
<tr>
<td width="800" align="center" valign="middle">
<font size="5"><font color="gold">The Roman Empire</font></font>
<br>
<a href="http://www.tregame.com" border="0"><img src="/img/spqr.jpg"></a>
<br>
</td>
</tr>

<tr>
<td width="800" align="center" valign="middle">
<center><h1>Edited/Created</h1>
<p>Room Edited/Created, go <a href="addroom.php">Back</a>.</p></center>
</td>
</tr>

<?php
}
else
{
?>

<body bgcolor="grey">
<table width="800"
       border="1"
       cellpadding="0"
       align="center"
       bgColor="CC0000">
<!-- Row 1 -->
<tr>
<td width="800" align="center" valign="middle">
<font size="5"><font color="gold">The Roman Empire</font></font>
<br>
<a href="http://www.tregame.com" border="0"><img src="/img/spqr.jpg"></a>
<br>
<?php
Print "You are editing $roomname <b>(Room Number): $roomin</b><br><br> It is connected to North: $north<br>South: $south<br>East: $east<br>West: $west<br>Up: $up<br>Down: $down"; 
?>
</td>
</tr>



<form action="addroom.php" method="post">
<table width="800"
       border="1"
       cellpadding="0"
       align="center"
       bgColor="CC0000">

<tr>
<td width="400" align="center" valign="middle">
Room Name:
</td>
<td width="400" align="center" valign="middle">
<INPUT TYPE="text" NAME="roomname" SIZE="30" value="<?php Print $roomname; ?>">
</td>
</tr>

<tr>
<td width="400" align="center" valign="middle">
Room Description:
</td>
<td width="400" align="center" valign="middle">
<TEXTAREA NAME="roomdesc" ROWS=6 COLS=40><?php Print $roomdesc; ?>
</TEXTAREA>
</td>
</tr>



<tr>
<td width="400" align="center" valign="middle">
Connect North To(Click checkbox too):
</td>
<td width="400" align="center" valign="middle">
<?php
print "<select name='north' length='20'>";
      $room1="SELECT * from rooms order by room";
      $room2=mysql_query($room1) or die("Could not select Room");
      while ($room3=mysql_fetch_array($room2))
      {
        print "<option>$room3[room]</option>";
      }
      print "</select><br>";
?>
<INPUT TYPE="checkbox" NAME="mnorth" VALUE="1">
</td>
</tr>

<tr>
<td width="400" align="center" valign="middle">
Connect South To(Click checkbox too if able to move south):
</td>
<td width="400" align="center" valign="middle">
<?php
print "<select name='south' length='20'>";
      $room1="SELECT * from rooms order by room";
      $room2=mysql_query($room1) or die("Could not select Room");
      while ($room3=mysql_fetch_array($room2))
      {
        print "<option>$room3[room]</option>";
      }
      print "</select><br>";
?>
<INPUT TYPE="checkbox" NAME="msouth" VALUE="1">
</td>
</tr>
<tr>
<td width="400" align="center" valign="middle">
Connect East To(Click checkbox too if able to move east):
</td>
<td width="400" align="center" valign="middle">
<?php
print "<select name='east' length='20'>";
      $room1="SELECT * from rooms order by room";
      $room2=mysql_query($room1) or die("Could not select Room");
      while ($room3=mysql_fetch_array($room2))
      {
        print "<option>$room3[room]</option>";
      }
      print "</select><br>";
?>
<INPUT TYPE="checkbox" NAME="meast" VALUE="1">
</td>
</tr>
<tr>
<td width="400" align="center" valign="middle">
Connect West To(Click checkbox too if able to move west):
</td>
<td width="400" align="center" valign="middle">
<?php
print "<select name='west' length='20'>";
      $room1="SELECT * from rooms order by room";
      $room2=mysql_query($room1) or die("Could not select Room");
      while ($room3=mysql_fetch_array($room2))
      {
        print "<option>$room3[room]</option>";
      }
      print "</select><br>";
?>
<INPUT TYPE="checkbox" NAME="mwest" VALUE="1">
</td>
</tr>
<tr>
<td width="400" align="center" valign="middle">
Connect Up To(Click checkbox too if able to move up):
</td>
<td width="400" align="center" valign="middle">
<?php
print "<select name='up' length='20'>";
      $room1="SELECT * from rooms order by room";
      $room2=mysql_query($room1) or die("Could not select Room");
      while ($room3=mysql_fetch_array($room2))
      {
        print "<option>$room3[room]</option>";
      }
      print "</select><br>";
?>
<INPUT TYPE="checkbox" NAME="mup" VALUE="1">
</td>
</tr>
<tr>
<td width="400" align="center" valign="middle">
Connect Down To(Click checkbox too if able to move down):
</td>
<td width="400" align="center" valign="middle">
<?php
print "<select name='down' length='20'>";
      $room1="SELECT * from rooms order by room";
      $room2=mysql_query($room1) or die("Could not select Room");
      while ($room3=mysql_fetch_array($room2))
      {
        print "<option>$room3[room]</option>";
      }
      print "</select><br>";
?>

<INPUT TYPE="checkbox" NAME="mdown" VALUE="1">
</td>
</tr>
<tr><th colspan=2><input type="submit" name="submit" value="Add Room"></th></tr> </table>
</form>
<table width="800"
       border="1"
       cellpadding="0"
       align="center"
       bgColor="CC0000">
<!-- Row 1 -->
<tr>
<td width="800" align="center" valign="middle">
<center><b><p>IMPORTANT:If you want the room to be able to connect to another, you have to click the check box. Also, if you reedit a room, you need to make sure that the previous connections are put back in place!</b></p></center>
</td>
</tr>

</table>

<?php
}
?> 

 

Now, when I edit a room, I have manually put in the direction of the previous room. Say, I want to add a room to the west, and I check the checkbox to enable movement to the west. What I don't know how to do, or go about doing, is making it so that the room to the west automatically updates to know that a room was added, and enable movement from the east back to the west.

 

Add room to the west: Move west, have to remember room number of West and add it into the East room via drop down box.

 

Now, another question:

 

Each time I reedit a room, the values become reset and do not retain the values I previously set. How do I make it so that the values are automatically set to what they previously were, like the room numbers?

 

Room 1 connects to room 123, for instance. How would I go about making so that each time I wanted to re-edit a room that the dropdown would be on room 123, and not back to 1?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.