CEinNYC Posted December 4, 2010 Share Posted December 4, 2010 Hello! I have all information, via Get, passing into battle.php correctly. In the Weapons Drop down, I need the selected weapon to pull from the correct associated number in the database. Do I pass that in the option value for each weapon? (Set a variable for each weapon)? (Whichever character has a higher number wins the battle). Thanks for any advice, keywords, etc..! <?php //require 'header.php'; //require 'footer.php'; mysql_connect('localhost', 'root', ''); //username and password of database mysql_select_db('giantbattlemonsters') or die( "Unable to select database"); //Character $sql = "SELECT * FROM game_char ORDER BY display_name ASC"; $results = mysql_query($sql) or die("Query failed with error: ".mysql_error()); // execute the query while ($row = mysql_fetch_assoc($results)) { $id[] = $row['id']; $display_name[] = $row['display_name']; } //Game Play $command ="SELECT * FROM game_char"; //options = mysql_fiend_name($command); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>8 Bit Battle</title> <link rel="stylesheet" type="text/css" media="screen" href="characters_style.css " /> </head> <body> <div class="wrapper"> <!-- <?php include 'header.php' ?> --> <div class = "content"> <div class = "player1_char"> <form action=battle.php METHOD=GET> <h1>Character #1</h1> <p> <select name="id1" style="font-size:20px;font-family:Arial;width:275px"> <?php for($i=0;$i<count($id);$i++) { echo "<option value ='".$id[$i]."'>".$display_name[$i]."</option>"; } ?> </select> </p> <p> <select name="weapon1" style="font-size:20px;font-family:Arial;width:275px"> <option value="power">Power</option> <option value="intelligence">Intelligence</option> <option value="speed">Speed</option> <option value="reserve">Reserve</option> </select> </p> </form> </div> <div class = "player2"> <form action=battle.php METHOD=GET> <h1>Character #2</h2> <p> <select name="id" style="font-size:20px;font-family:Arial;width:275px"> <?php for($i=0;$i<count($id);$i++) { echo "<option value='".$id[$i]."'>".$display_name[$i]."</option>"; } ?> </select> </p> <p> <select name="weapon2" style="font-size:20px;font-family:Arial;width:275px"> <option value="power">Power</option> <option value="intelligence">Intelligence</option> <option value="speed">Speed</option> <option value="reserve">Reserve</option> </select> </p> <input type=submit value="Fight!" Class=button> </p> </form> </div> </div> </div> </body> [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/220674-next-step-select-where-dropdown-menus/ Share on other sites More sharing options...
fenway Posted December 5, 2010 Share Posted December 5, 2010 I've locked your other two topics -- clearly, you're starting a new thread for each incremental change to the same script. Please keep the discussion in a SINGLE thread. Also, it's bad form to post an entire script. Quote Link to comment https://forums.phpfreaks.com/topic/220674-next-step-select-where-dropdown-menus/#findComment-1143289 Share on other sites More sharing options...
CEinNYC Posted December 5, 2010 Author Share Posted December 5, 2010 Will do.. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/220674-next-step-select-where-dropdown-menus/#findComment-1143298 Share on other sites More sharing options...
fenway Posted December 5, 2010 Share Posted December 5, 2010 Will do.. Thanks. Great. Now, back to your question -- which code snippet are we talking about/ Quote Link to comment https://forums.phpfreaks.com/topic/220674-next-step-select-where-dropdown-menus/#findComment-1143303 Share on other sites More sharing options...
CEinNYC Posted December 8, 2010 Author Share Posted December 8, 2010 Thanks for this.. I'm looking to join this information: <p> <select id="weapon1" name="weapon1" style="font-size:20px;font-family:Arial;width:275px"> <option value="power">Power</option> <option value="intelligence">Intelligence</option> <option value="speed">Speed</option> <option value="reserve">Reserve</option> </select> </p> with this information: $join = "SELECT * FROM game_weapons"; $weapons_results = mysql_query($join); while($row2 = mysql_fetch_assoc($weapons_results)) { if($row2["id"] == $id1) { $weapon_value1 = $row[$weapon1]; $name1 = $row2["id"]; } if($row2["id"] == $id2) { $weapon_value2 = $row[$weapon2]; $name2 = $row2["id"]; } } picture of the database attached. Thank you! Perhaps I'm populating the drop down box incorrectly? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/220674-next-step-select-where-dropdown-menus/#findComment-1144267 Share on other sites More sharing options...
fenway Posted December 8, 2010 Share Posted December 8, 2010 I'm not sure I'm clear on what you're trying to do -- you want the IDs as the values/ Quote Link to comment https://forums.phpfreaks.com/topic/220674-next-step-select-where-dropdown-menus/#findComment-1144490 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.