私は一日中このコードを探していましたが、うまくいきませんでした.グーグルでコードを見つけたときに、それが機能していないことは明らかだったので、独自の方法で編集しました.ですから、誰かがこのコードで私を助けてくれたらとてもうれしいです。
私が欲しいのは、ラジオボタンを選択してEnterキーを押すと、次のページが表示され、ラジオボタンに従ってデータベースデータが表示されるはずです。データベースデータを除外するデータベースフィルターのようなものです..
ということで、まずは最初のページを……。 FILTERPAGE.HTML
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>FILTER PAGE</title>
</head>
<body>
<form action="search.php" method="post" name="filter_option">
<table width="100%" border="0">
<tr>
<td>
<label>
<input name="filter_options" type="radio" id="filter_options_0" value="default_filter" checked>
Default</label>
</td>
<td><label>
<input type="radio" name="filter_options" value="special_id_filter" id="filter_options_1">
Special ID</label></td>
<td><label>
<input type="radio" name="filter_options" value="company_name_filter" id="filter_options_2">
Company Name</label></td>
<td><label>
<input type="radio" name="filter_options" value="brand_name_filter" id="filter_options_3">
Brand Name</label></td>
<td><label>
<input type="radio" name="filter_options" value="model_id_filter" id="filter_options_4">
Model ID</label></td>
<td><label>
<input type="radio" name="filter_options" value="colour_filter" id="filter_options_5">
Colour</label></td>
<td><label>
<input type="radio" name="filter_options" value="size_filter" id="filter_options_6">
Size</label></td>
<td><label>
<input type="radio" name="filter_options" value="frame_type_filter" id="filter_options_7">
Frame Type</label></td>
<td><label>
<input type="radio" name="filter_options" value="frame_for_filter" id="filter_options_8">
Frame For</label></td>
<td><label>
<input type="radio" name="filter_options" value="quantity_filter" id="filter_options_9">
Quantity</label></td>
<td><label>
<input type="radio" name="filter_options" value="price_filter" id="filter_options_10">
Price</label></td>
</tr>
</table>
<input name="submit" type="submit">
</form>
</body>
</html>
そして今ここにPHPのものである2番目のものがあります........ SEARCH.PHP
<?php
mysql_connect("localhost","root","password") or die(mysql_error());
mysql_select_db("stock_entry") or die(mysql_error());
$filteroption= $_POST['filter_options'];
//To use different queries while searching
if ($filteroption == 'default_filter')
{
$queres = "SELECT * FROM stock_entry_spectacles ORDER BY 'id'";
}
else if ($filteroption == 'special_id_filter')
{
$queres = "SELECT * FROM stock_entry_spectacles ORDER BY 'special_id'";
}
else if ($filteroption == 'company_name_filter')
{
$queres = "SELECT * FROM stock_entry_spectacles ORDER BY 'company_name'";
}
else if ($filteroption == 'brand_name_filter')
{
$queres = "SELECT * FROM stock_entry_spectacles ORDER BY 'brand_name'";
}
else if ($filteroption == 'model_id_filter')
{
$queres = "SELECT * FROM stock_entry_spectacles ORDER BY 'model_id'";
}
$query = $queres;
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)){
echo "<table class='data' border='0' cellspacing='2' align='center'>
<tr>
<td align='center' class='special_id'><input type='text' name='id' value='".$row['special_id']."'></td>
<td align='center' class='company_nametd'><input type='text' name='company_name' value='".$row['company_name']."'></td>
<td align='center' class='brand_namestd'> <input type='text' name='brand_name' value='".$row['brand_name']."'></td>
<td align='center' class='model_idtd'> <input type='text' name='model_id' value='".$row['model_id']."'></td>
<td align='center' class='colour_selecttd'> <input type='text' name='colour_select' value='".$row['colour_select']."'></td>
<td align='center' class='size_selecttd'> <input type='text' name='size_select' value='".$row['size_select']."'></td>
<td align='center' class='type_selecttd'><input type='text' name='type_select' value='".$row['type_select']."'></td>
<td align='center' class='for_selecttd'> <input type='text' name='for_select' value='".$row['for_select']."'></td>
<td align='center' class='quantitytd'> <input type='text' name='quantity' value='".$row['quantity']."'></td>
<td align='center' class='pricetd'> <input type='text' name='price' value='".$row['price']."'></td>
<tr>
</table>";
}
?>
最後に、Mysql 構造について......
データベース名:stock_entry
テーブルのテーブル構造stock_entry_spectacles
CREATE TABLE IF NOT EXISTS `stock_entry_spectacles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`special_id` int(225) DEFAULT NULL,
`company_name` text COLLATE utf8_unicode_ci,
`brand_name` text COLLATE utf8_unicode_ci,
`model_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_polish_ci DEFAULT NULL,
`colour_select` text COLLATE utf8_unicode_ci,
`size_select` int(11) DEFAULT NULL,
`type_select` text COLLATE utf8_unicode_ci,
`for_select` text COLLATE utf8_unicode_ci,
`quantity` int(11) DEFAULT NULL,
`price` int(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ;
テーブルのデータをダンプしていますstock_entry_spectacles
INSERT INTO `stock_entry_spectacles` (`id`, `special_id`, `company_name`, `brand_name`, `model_id`, `colour_select`, `size_select`, `type_select`, `for_select`, `quantity`, `price`) VALUES
(1, NULL, 'Titan', 'abc', '123', 'GunMetal', 50, 'Metal', 'Male', 2, NULL),
(2, NULL, 'AO Specs', 'def', '456', 'Black', 48, 'Metal', 'Male', 6, 500),
(3, NULL, 'Sinora', 'ghi', '789', 'Blue', 13, 'broad sided', 'Female', 3, 460),
(4, NULL, 'Tommy', 'jkl', '963', 'GunMetal', 40, 'Shell', 'Male', 8, 800),
(5, 14873273, 'Manav', 'mno', '852', 'Black', 50, 'Metal', 'Male', 5, 120);
私のプロジェクトの1つにこのコードが必要だったので、誰か助けてください....