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>"
?>
相关文档:
今天为了一些已有数据导入MYSQL的数据库,我写了一个很简单的PHP程序。
程序思路很简单,就是读一条数据,然后往MYSQL里插入一条。
结果总是发现 每次导入只能导入2000条,就自动停止了,而且没有任何提示。
在网上搜解决方案各种搜不到。
刚开始怀疑是内存缓冲给少了,调了一下,还是不行。。
最后发现一个规律,就是 ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>PHP分页</tit ......
/***************************by
garcon1986********************************/
<?php
//php avancé 5 example
$a = 'hello';
$a .= 'world';
$table = 'users';
$id = 5;
$sql = 'SELECT * from'.$table. "WHERE ID = '$id'";
//date() G显示24小时的格式,i显示分钟
echo 'il est'.date( ......
/***************************by
garcon1986********************************/
<?php
// example for strings, single quoted, double quoted
echo 'display a string!<br>';
echo ' this displays
a splitted
string<br>';
echo 'i\'ll be "back"<br>';
echo 'she said:"i ......
/***************************by garcon1986**************************/
form.html
<html>
<head>
<title>Upload File</title>
</head>
<body>
<form enctype="multipart/form-data" method="POST" action="uploader.php">
<label> ......