你上面用的char也可以 用int也行,0为男,1为女,这些就是一个标志,不一定数据库中必须为男女 只要程序能读的懂能表达的清楚就ok了
input type="radio" name="sex" value="男" ?php if ($sex=='男') echo "checked" ;? /
input type="radio" name="sex" value="女" ?php if ($sex=='女') echo "checked" ;? /
$sex是你的性别变量名
调用指定ID,例如查看张三的简历
php
$link=mysql_connect("localhost","root","root");//账号,密码?
if(!$link)?echo?"没有连接成功!";?
mysql_select_db("data1",?$link);//选择数据库?
$sql?=?"SELECT?*?FROM?info?where?id=1";//SQL查询语句,指定你要获取的ID,info为表名???
$rs?=?mysql_query($sql,?$link);//获取数据集?
$row=mysql_fetch_array($rs);
tr
td?bgcolor="#CCCCCC"nbsp;姓名/td
td?bgcolor="#CCCCCC"nbsp;年龄/td
td?bgcolor="#CCCCCC"nbsp;性别/td
td?bgcolor="#CCCCCC"nbsp;籍贯/td
/tr
tdnbsp;?php?echo?$row['name'];?/td
tdnbsp;?php?echo?$row['age'];?/td
tdnbsp;?php?echo?$row['sex'];?/td
tdnbsp;?php?echo?$row['hometown'];?/td
/table
以上将输出张三的建立信息.
你是什么数据库,不同数据库调用方法也不同,比如mysql,一般写法,
$link=mysql_connect("localhost","root","root");//连接数据库
mysql_select_db("库名");//选择库
$sql="select?name,sex,age?from?user";
$rs=mysql_query($sql);
while($row=mysql_fetch_object($rs)){?
trtd?php?echo?$row['name']?/tdtd?php?echo?$row['sex']?/tdtd?php?echo?$row['age']?/td/tr
php?}?
查看一下代码:
//?获取表单提交值
$student_id?=?intval(trim($_POST['student_id']));
//?页面表单?可以放单独的html文件中,如果放单独的html页面中?form?的action的地址要改成下面的PHP文件名
echo?'form?action=""?method="post"
input?type="text"?name="student_id"?value="{$student_id}"/
input?type="submit"?name="submit"?value="查询"/
/form';
//?当有数据提交时
if?($student_id)
{
$con=?mysql_connect("localhost","root","111")?or?die("连接错误");
mysql_select_db("examination",$con);
//?查询
$sql?=?"SELECT?*?FROM?tablename?WHERE?student_id?=?$student_id?";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
//?输出
echo?'学号:'.$row['student_id'].'br姓名:'.$row['name'].'br性别:'.$row['gender'].'br分数:'.$row['score'];
}