Mysql Query
Posted: Wed Mar 29, 2006 9:53 pm
feyd | Please use
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Below is a simple code that allows a user to enter a name and it searches the table skills_warrior for that skill the user entered. however i want this script to search multiple tables, like skills_warrior, skills_monk, skills_necromancer ect... how do i do that?Code: Select all
$sql_row = $_POST['sql_row'];
$skillname = $_POST['skill_name'];
$db = mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db($dbname, $db);
$result = mysql_query("SELECT * FROM skills_warrior WHERE $sql_row='$skillname'", $db);
echo "Skill Name:
<br>
<form method = 'post' action = 'index.php'>
<select name='sql_row'>
<option>Name</option>
<option>Mana</option>
<option>Recharge</option>
<option>Trainer</option>
</select><br>
<input type = 'text' name = 'skill_name'>
<input type = 'submit' value = 'Go'>
<br>
<br>";
while ($row = mysql_fetch_array($result))
{
echo "<table width=\"600\" cellpadding=\"3\" cellspacing=\"2\" border=\"1\">
<tr><td width=\"100\"> Skill</td><td>" . $row["name"] . "</td>
<td rowspan=\"5\" width=\"55\"><center>
<img src=\"".$row["image"]."\" width=\"64\" height=\"64\">
</center></td></tr>
<tr><td width=\"100\"> Description</td>
<td>" . $row["description"] . "</td></tr>
<tr><td width=\"100\">Mana</td>
<td>" . $row["mana"] . "</td>
</tr>
<tr><td width=\"100\">Recast Time</td><td>" . $row["recharge"] . "</td></tr>
<tr><td width=\"100\">Location</td><td> Trainer: " . $row["location"] . "</td></tr>
</table><br>";
}
?>feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]