Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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">

<header class="mast-head stack-fixed clearfix">









<!-- end .main-nav -->

</header>













<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>


























<!-- 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">

<header class="mast-head stack-fixed clearfix">









<!-- end .main-nav -->

</header>













<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 "
FieldValue
Name<input type='text' name='uName' readonly='readonly' value='".$row['Name']."'>
GenderMale<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']."'>
Email<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>


























<!-- 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>
Posted

As far as I can see, these are my findings from your second code block:
1. action="process-update.html" is wrong, the action value must be a server side script that ends with php extension, not html.
2. You are still not careful on the quotes, value='".$row['Name']."' should be value='".$row['Name']."'" and other similar mistakes
3. why are there so many echo""?
4. why if ($fgender == "Male") echo"" else echo""? Did not make sense.
Btw, did my answer to your previous question help?
 
Share this answer
 
Comments
Killzone DeathMan 3-Feb-14 6:38am    
Response for point 4: He just forget to type some random text :P
Peter Leow 3-Feb-14 7:28am    
speechless.
Killzone DeathMan 6-Feb-14 12:18pm    
It was just a joke :D
I dont know why there are so many echo"" x)
Peter, i m jus trying with only one column. Still it doesnt work. I ve compared the code with my friends's one. It was almost same but theirs was working.

XML
<form action="process-update.php" method="post">
                    <?php
        $selname = $_POST['name'];
        {
        $result = mysql_query("SELECT * FROM member WHERE Name = '".$selname."'", $connection);
        }
        echo "<table border='1'><tr><th>Field</th><th>Value</th></tr>";

        while($row = mysql_fetch_array($result))
        {
        echo "<tr><td> Name</td><td><input type='text' name='uName' value='" . $row['Name'] . "'></td></tr>";
        }
        echo "</table>";

        mysql_close($connection);

        ?>
        Update<input type='radio' name='fAction' value='Update' checked> <br/>
        Delete<input type='radio' name='fAction' value='Delete'> <br/>

            <button type="submit">Submit</button>
                    </form>
 
Share this answer
 
Comments
Peter Leow 6-Feb-14 19:13pm    
How can 'almost same'? Do you see any wrong with this line of your code: value='" . $row['Name'] . "'>
I say again, you should not add your additional input as solution, add it in the original question using the 'Improved question' widget. Again, one glance, the same mistakes surfaced, misplaced quotes. Try to be patient, careful, and meticulous in your coding. No short cut.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900