I'm making a website for a multi-player roleplay game.
I have a php page where players can go to enter information about their characters. This page works just fine, but I would like to add something to make it work a little easier for the players. Basically, when the player is adding or editing their information, there is a section for them to enter their "equipment". I would like for them to be able to select the appropriate choice from a drop down list.
What my tables look like (I only included relevent fields)
Table 1 - characters
id (This is the character id)
weapon1 (This is the name of their weapon)
type1 (This is the type of weapon)
Table 2 - equipment
id
name
type
So basically, I want the drop down list to include the names of all the entries in the equipment table. Once a person selects an option, I want the character table to update any relevent information (name, type) in the appropriate fields (weapon1, type1)
I've looked for some tutorials for some of this. I tried to break it down into parts... first I focused on making the drop list populate from the equipment database. I'm sort of stuck however, how to go from here. The following code will populate the list, but if I hit submit, I get an authorization error. That's either some error in the code, or I need to change some permission somewhere, though that seems unlikely...
<?php
include("xxxx.php");
mysql_select_db("xxxxxx", $con);
if(isset($select)&&$select!=""){
$select=$_GET['select'];
}
?>
<html>
<body>
<form id="weapon1" name="weapon1" method="get" action="<?php echo $SCRIPT_NAME ; ?> ">
Weapon :
<select name="select">
<option value="">--- Select ---</option>
<?
$list=mysql_query("select * from equipment order by id asc");
while($row_list=mysql_fetch_assoc($list)){
?>
<option value="<?php echo $row_list['id']; ?>" <?php if($row_list['id']==$select){ echo "selected"; } ?>><?php echo $row_list['name']; ?></option>
<?php
}
?>
</select>
<input type="submit" name="Submit" value="Select" />
</form>
<?php
mysql_close();
?>
(The original tutorial code didn't work right, so I sort of tore it apart and made it .. sort of work.)
So, ideally, after you hit submit, it should stay on the same page, and show a list like -
Weapon: Dagger
Type: Piercing
Then maybe a confirm button... then enter this information into the character table... This all has to be inside of a php page that edits the entire character table. I'm not very good at accessing multiiple tables to begin with, lol. I really hope I've explained this well, please feel free to ask me anything that needs clarification. I'm really fairly new at php, I'm sure this is some pretty easy solution, but I've been staring at far too many codes today lol.
I appreciate any help anyone can offer.
Thank you!