我正在创建一个我想使用Php从数据库更新数据的站点。但是在更新数据之前我无法检索和显示。 [英] I Am Creating A Site Where I Want To Update The Data From Database Using Php. But I Am Unable To Retrieve And Display Before Updating Data.
问题描述
这些是我的代码
1)当我想更新一个人的详细信息时,我必须首先选择这个人。
<!doctype html>
<! - [if lt IE 7]> ; < html class =no-js ie6 oldielang =en> <![endif] - >
<! - [if IE 7]> < html class =no-js ie7 oldielang =en> <![endif] - >
<! - [if IE 8]> < html class =no-js ie8 oldielang =en> <![endif] - >
<! - [if gt IE 8]><! - >
< html class =no-jslang =en>
<! - <![endif] - >
< head>
< meta charset =utf-8>
< meta http-equiv =X-UA-Compatiblecontent =IE = edge,chrome = 1 >
< title>社区之夜自行车2014新加坡< / title>
< meta name =viewportcontent =width = device-width,initial -scale = 1,maximum-scale = 1.0,user-scalable = no>
< meta name =googlebotcontent =index,follow/>
< meta name =descriptioncontent =/>
< meta name =keywordscontent =/>
< ; meta name =authorcontent =/>
< link rel =stylesheethref =style / general.css/>
< link rel =stylesheethref =style / framework.css/>
< link rel =stylesheethref =style / site.css/>
< script src =js /modernizr-2.0.6.min.jstype =text / javascript>< / script>
< / head>
< body class =联系>
These are my codes
1) When I want to update a person's details, I have to first choose the person.
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Community Night Cycling 2014 Singapore</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0,user-scalable = no">
<meta name="googlebot" content="index, follow" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<link rel="stylesheet" href="style/general.css" />
<link rel="stylesheet" href="style/framework.css" />
<link rel="stylesheet" href="style/site.css" />
<script src="js/modernizr-2.0.6.min.js" type="text/javascript"></script>
</head>
<body class="contact">
< form name =inputaction =insert-update.phpmethod =POST>
$ result = mysql_query(SELECT * FROM members,$ connection);
echo'SELECT Name< select name =name>';
while($ row = mysql_fetch_array($ result))
{
echo< option value ='。$ row ['Name']。'> ;。$ row ['Name']。< / option>;
}
echo< / select>;
?>
< input type =submitvalue =提交& gt;
< / form>
<form name="input" action="insert-update.php" method="POST">
$result = mysql_query("SELECT * FROM members ", $connection);
echo 'SELECT Name <select name="name">';
while($row=mysql_fetch_array($result))
{
echo "<option value='".$row['Name']."'>".$row['Name']."</option>";
}
echo "</select>";
?>
<input type="submit" value="Submit">
</form>
- awesome@egrappler.com
- Connect on Twitter
- Share With Your Friends
- Help
- Home
- Registration
- Administrator Page
- Statistics
<! - end .mother - >
< script src =js / jquery.min.jstype =text / javascript>< / script>
< script defer src =js / accessories-min.jstype = text / javascript>< / script>
< script defer src =js / site.jstype =text / javascript>< / script>
<! - [if lt IE 7]>
< script src =// ajax.googleapis.com/ajax/libs/chrome-frame/1.0。 3 / CFInstall.min.js>< / script>
< script> window.attachEvent('onload',function() {CFInstall.check({mode:'overlay'})})< / script>
<![endif] - >
< / body> ;
< / html>
2)从下拉列表中选择此人后,点击上一页的提交,它重定向到此页面。在这里,我有问题检索和显示数据以及更新细节的输入类型。我觉得问题来自于while循环becoz我只能看到表格边框显示字段和值:
<!doctype html>
<! - [if lt IE 7]> < html class =no-js ie6 oldielang =en> <![endif] - >
<! - [if IE 7]> < html class =no-js ie7 oldielang =en> <![endif] - >
<! - [if IE 8]> < html class =no-js ie8 oldielang =en> <![endif] - >
<! - [if gt IE 8]><! - >
< html class =no-jslang =en>
<! - <![endif] - >
< head>
< meta charset =utf-8>
< meta http-equiv =X-UA-Compatiblecontent =IE = edge,chrome = 1 >
< title>社区之夜自行车2014新加坡< / title>
< meta name =viewportcontent =width = device-width,initial -scale = 1,maximum-scale = 1.0,user-scalable = no>
< meta name =googlebotcontent =index,follow/>
< meta name =descriptioncontent =/>
< meta name =keywordscontent =/>
< ; meta name =authorcontent =/>
< link rel =stylesheethref =style / general.css/>
< link rel =stylesheethref =style / framework.css/>
< link rel =stylesheethref =style / site.css/>
< script src =js /modernizr-2.0.6.min.jstype =text / javascript>< / script>
< / head>
< body class =联系>
<!-- end .mother -->
<script src="js/jquery.min.js" type="text/javascript"></script>
<script defer src="js/accessories-min.js" type="text/javascript"></script>
<script defer src="js/site.js" type="text/javascript"></script>
<!--[if lt IE 7 ]>
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
<script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
<![endif]-->
</body>
</html>
2)After I choose the person from the dropdown list and click on Submit from thee previous page, it redirects to this page. Here I am having problem to retrieve and display the data as well as the input types to update particulars. I feel tat the problem is coming from the while loop becoz I can only see the table border displaying field and value:
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Community Night Cycling 2014 Singapore</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0,user-scalable = no">
<meta name="googlebot" content="index, follow" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<link rel="stylesheet" href="style/general.css" />
<link rel="stylesheet" href="style/framework.css" />
<link rel="stylesheet" href="style/site.css" />
<script src="js/modernizr-2.0.6.min.js" type="text/javascript"></script>
</head>
<body class="contact">
< form name =inputaction =process-update.htmlmethod =post>
$ selname = $ _ POST ['name'];
{
$ result = mysql_query(SELECT * FROM members WHERE Name ='。$ selname。 ',$连接);
}
echo;
while($ row = mysql_fetch_array($ result))
{
echo;
$ fgender = $ row ['性别'];
如果($ fgender ==男)
{
echo;
}
其他
{
echo;
}
echo;
echo;
echo;
echo;
echo;
}
echo
字段 | 值 |
---|---|
名称 | < input type = 'text'name ='uName'readonly ='readonly'value ='。$ row ['Name']。'> |
性别 | < td>男性<输入类型='无线电'名称='uGender'值='男性'已检查>;|
性别 | 男性<输入类型='无线电'名称='uGender'值='男性'>; echo女性<输入类型='无线电'名称='uGender'值='女性'已检查> |
年龄 | < input type ='text'name ='uAge'value ='。$ row ['Age']。'> |
电子邮件 | < TD>< INP ut type ='text'name ='uEmail'value ='。$ row ['Email']。'>|
NRIC | < input type ='text'name ='uNRIC'value ='。$ row ['NRIC']。'> |
地址 | < td>< textarea name ='uAddress'value ='。$ row ['Address']。'>|
ZipCode | < ; input type ='text'name ='uZipCode'value ='。$ row ['Contact']。'> |
mysql_close($ connection);
?>
更新<输入类型='radio'name ='fAction'value ='更新'选中>
删除< input type ='radio'name ='fAction'value ='删除'>
< input type =submitvalue =Submit>
< / form>
<form name="input" action="process-update.html" method="post">
$selname=$_POST['name'];
{
$result=mysql_query("SELECT * FROM members WHERE Name = ' ".$selname." ' ", $connection);
}
echo "";
while($row = mysql_fetch_array($result))
{
echo "";
$fgender = $row['Gender'];
if ($fgender == "Male")
{
echo "";
}
else
{
echo "";
}
echo "";
echo "";
echo "";
echo "";
echo "";
}
echo "
Field | Value |
---|---|
Name | <input type='text' name='uName' readonly='readonly' value='".$row['Name']."'> |
Gender | Male<input type='radio' name='uGender' value='Male' checked>"; echo "Female<input type='radio' name='uGender' value='Female'> |
Gender | Male<input type='radio' name='uGender' value='Male'>"; echo "Female<input type='radio' name='uGender' value='Female' checked> |
Age | <input type='text' name='uAge' value='".$row['Age']."'> |
<input type='text' name='uEmail' value='".$row['Email']."'> | |
NRIC | <input type='text' name='uNRIC' value='".$row['NRIC']."'> |
Address | <textarea name='uAddress' value='".$row['Address']."'> |
ZipCode | <input type='text' name='uZipCode' value='".$row['Contact']."'> |
mysql_close($connection);
?>
Update<input type='radio' name='fAction' value='Update' checked>
Delete<input type='radio' name='fAction' value='Delete'>
<input type="submit" value="Submit">
</form>
- awesome@egrappler.com
- Connect on Twitter
- Share With Your Friends
- Help
- Home
- Registration
- Administrator Page
- Statistics
<! - end .mother - >
< script src =js / jquery.min.jstype =text / javascript>< /脚本>
< script defer src =js / accessories-min.jstype =text / javascript>< / script>
< script defer src =js / site.jstype =text / javascript>< / script>
<! - [if lt IE 7]>
< script src =// ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js\"></script>
<脚本> window.attachEvent( '的onload',函数(){CFInstall.check({模式: '叠加'})})< / SCR ipt>
<![endif] - >
< / body>
< / html>
<!-- end .mother -->
<script src="js/jquery.min.js" type="text/javascript"></script>
<script defer src="js/accessories-min.js" type="text/javascript"></script>
<script defer src="js/site.js" type="text/javascript"></script>
<!--[if lt IE 7 ]>
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
<script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
<![endif]-->
</body>
</html>
推荐答案
result = mysql_query(SELECT * FROM members,
result = mysql_query("SELECT * FROM members ",
connection);
echo'SELECT Name < select name =name>';
while(
connection);
echo 'SELECT Name <select name="name">';
while(
row = mysql_fetch_array(
row=mysql_fetch_array(
这篇关于我正在创建一个我想使用Php从数据库更新数据的站点。但是在更新数据之前我无法检索和显示。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!