PHP获取radio值,并用作参数查询数据库,同一页面显示

/***************************by garcon1986************************************/ <?php error_reporting(E_ALL ^ E_NOTICE); //create database test //create table php_radio(id int(10) NOT NULL AUTO_INCREMENT, name varchar(100), description varchar(1000), primary key(id)); //insert php_radio values(1, 'eat','you have eaten ...'); //insert php_radio values(2, 'drink', 'you have drank ...'); //insert php_radio values(3, 'sleep', 'you have sleep ...'); echo "<html><head></head>"; echo "<body>"; echo "<form action='use_radio.php' method='GET'>"; echo "<input type='radio' name='radio' value='eat'>Eat</input>"; echo "<input type='radio' name='radio' value='drink'>Drink</input>"; echo "<input type='radio' name='radio' value='sleep'>Sleep</input>"; echo "<input type='submit' name='search_radio' value='Button' />"; echo "</form>"; $radio_name = $_GET['radio']; //echo $radio_name; mysql_connect("localhost","charles","charles"); mysql_select_db("test"); $query = 'select * from php_radio where name = "'.$radio_name.'"'; //echo $query; $result = mysql_query($query) or die("query error: ".mysql_error()); while($aa = mysql_fetch_assoc($result)){ echo $aa['id']." "; echo $aa['name']." "; echo $aa['description']."<br>"; } //mysql_free_result($result); echo "</body>"; echo "</html>" ?>

你可能感兴趣的:(PHP,mysql,数据库,database,query,input)