Jump to content

Recommended Posts

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]

Link to comment
https://forums.phpfreaks.com/topic/220674-next-step-select-where-dropdown-menus/
Share on other sites

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]

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.