0

hye guys..
i've got a problem on inserting the data from mysql database into the textbox in php..
i dont get any error reply..but im still cant retrieve the data from the mysql database into text box in php..
below are the print screen and my sourcecode:
this is the source code for ReadID.htm

<html>
<head>
<title>Update Details</title>
<meta http-equiv = "Content-Type" content = "text/html; charse=iso-8859-1">
</head>
<body bgcolor = "#FFFFFF" text = "#000000">
<p>&nbsp;</p>
<form name = "ReadID" method="post" action = "displayform.php">
	<table width = "250" border = "0" align = "center" cellpadding = "3">
		<tr>
		    <td colspan = "2" bgcolor = "#dddddd" height = "23">
		        <center><b>Enter the Doctor ID</b></center>
		    </td>
		</tr>
		
		<tr bgcolor = "#eeeeee">
		    <td width = "100" bgcolor = "#eeeeee">
			<center>Doctor ID</center>
		    </td>
		

		<td width = "150">
			<input type = "text" name = "DocID">
			</td>
		</tr>
			<td colspan  = "2" bgcolor = "#dddddd">
				<center>
					<input type = "submit" name = "Submit" value = "Submit">
				</center>
			</td>
		</tr>
	</table>
</form>
</body>
</html>

This is the source code for dislplayform.php:

<!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=utf-8" />
<title>Update Doctor Information</title>
<style type="text/css">
<!--
.DocName {
	text-align: right;
}
.Address {
	text-align: right;
}
.PostCode {
	text-align: right;
}
td {
	text-align: right;
}
-->
</style>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p>&nbsp;</p><form name="displayform" method="post" action="update.php">
	<table width="250" border="0" align="center" cellpadding="3">
    <tr>
    <td colspan="2" bgcolor="#999999">
    <div align="center"><b>Update Doctor Information</b></div>
    </td>
    </tr>

<?php
$host = "localhost";
  $uname = "root";
  $pass = "1234";
 // $database = "klinik_kucing";
  $tablename = "Doctor";
  $con = mysql_connect($host, $uname, $pass)
      or die ("Database connection failed!<br>");

  mysql_select_db("klinik_kucing",$con);
	$id = $_GET['id'];
  $sql="select * from Doctor where DocID='$id'";

$result=mysql_query($sql);
$row=mysql_fetch_array($result);
  ?>
  
<table width="250" border="0" align="center" cellpadding="3">
  <tr bgcolor="#eeeeee">
  	<td width = "100" bgcolor = "#eeeeee">
    <div align = "right">Name</div>
    </td>
    <td width = "150">
    <input type = "text" name = "DocName" value = "<? echo $row['DocName']; ?>" >
    </td>
    </tr>
    <tr bgcolor = "#eeeeee">
    <td width = "100" bgcolor = "#eeeeee">
	<div align="right" > Address</div>
    </td>
    <td width = "150">
    <input type="text" name = "Address" value ="<?php echo $row['Address']; ?>"/>
    </td>
    </tr>
    <tr bgcolor = "#eeeeee">
    <td width = "100" bgcolor = "#eeeeee">
    <div align = "right" >PostCode</div>
    </td>
    <td width = "150">
    <input type = "text" name="PostCode" value="<?php echo $row['Postcode']; ?>" />
    </td>
    </tr>
    <tr bgcolor = "#eeeeee">
    <td width = "100" bgcolor = "#eeeeee">
    <div align = "right" >City</div>
    </td>
    <td width = "150">
    <input type = "text" name="City" value="<?php echo $row['City']; ?>" />
    </td>
    </tr>
<tr bgcolor = "#eeeeee">
    <td width = "100" bgcolor = "#eeeeee">
    <div align = "right" >State</div>
    </td>
    <td width = "150">
    <input type = "text" name="State" value="<?php echo $row['State']; ?>" />
    </td>
    </tr>
<tr bgcolor = "#eeeeee">
    <td width = "100" bgcolor = "#eeeeee">
    <div align = "right" >Gender</div>
    </td>
    <td width = "150">
    <input type = "text" name="Gender" value="<?php echo $row['Gender']; ?>" />
    </td>
    </tr>
<tr bgcolor = "#eeeeee">
    <td width = "100" bgcolor = "#eeeeee">
    <div align = "right" >PhoneNum</div>
    </td>
    <td width = "150">
    <input type = "text" name="PhoneNum" value="<?php echo $row['PhoneNum']; ?>" />
    </td>
    </tr>
<tr bgcolor = "#eeeeee">
    <td width = "100" bgcolor = "#eeeeee">
    <div align = "right" >DateJoin</div>
    </td>
    <td width = "150">
    <input type = "text" name="DateJoin" value="<?php echo $row['DateJoin']; ?>" />
    </td>
    </tr>
    <td colspan="2" bgcolor="#dddddd" >
    <div align="center"> 
    <input type="submit" name="Submit" value="Update" />
    </div>
    </td>
    </tr>
    
    
    
</table>
</form>
</body>
</html>

and this is the source code for update.php:

<!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=utf-8" />
<title>New Doctor Record</title>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p>&nbsp;</p>
<?php
$host = "localhost";
$uname = "root";
$pass = "1234";
$database = "klinik_kucing";
$tablename = "Doctor";
$con = mysql_connect($host, $uname, $pass)
	or die ("Database connection failed!<br>");
$result = mysql_select_db($database)
	or die ("Database could not be selected");
$query = "Update Doctor set DocName = \"".$DocName."\",Address = \"".$Address."\",Postcode = \"".$Postcode."\",City = \"".$City."\",State = \"".$State."\",PhoneNum = \"".$PhoneNum."\",DateJoin = \"".$DateJoin."\" where DocID =\"".$DocID."\"";
$result = mysql_query ($query);
if (!$result)
{
	die ("Query could not be executed.<br>");
}
else
{
	echo "<table border = \"0\" align = \*center\* cellspacing = \"1\" cellpadding = \"5\" width = \"300\">";
	echo "<tr>";
	echo "<td colspan = \"2\" bgcolor = \"#dddddd\">";
	echo "<center><b>".mysql_affected_rows()." record updated succesfully</b></center>";
	echo "</td>";
	echo "</tr>";
	echo "<tr bgcolor = \"#eeeeee\">";
	echo "<td width = \"200\" bgcolor = \*#eeeeee\*>";
	echo "<div align = \"right\">Name:</div>";
	echo "</td>";
	echo "<td width = \"200\">".$DocName."</td>";
	echo "</tr>";
	echo "<tr bgcolor = \"#eeeeee\">";
	echo "<td width = \"200\" bgcolor = \*#eeeeee\*>";
	echo "<div align = \"right\">Address:</div>";
	echo "</td>";
	echo "<td width = \"200\">".$Address."</td>";
	echo "</tr>";
	echo "<tr bgcolor = \"#eeeeee\">";
	echo "<td width = \"200\" bgcolor = \"$eeeeee\">";
	echo "<div align = \"right\">Postcode:</div>";
	echo "</td>";
	echo "<td width = \"200\">".$PostCode."</td>";
	echo "</tr>";
	echo "<tr bgcolor = \"#eeeeee\">";
	echo "<td width = \"200\" bgcolor = \*#eeeeee\*>";
	echo "<div align = \"right\">City:</div>";
	echo "</td>";
	echo "<td width = \"200\">".$City."</td>";
	echo "</tr>";
	//echo "<tr>";
	echo "<tr bgcolor = \"#eeeeee\">";
	echo "<td width = \"200\" bgcolor = \*#eeeeee\*>";
	echo "<div align = \"right\">State:</div>";
	echo "</td>";
	echo "<td width = \"200\">".$State."</td>";
	echo "</tr>";
	echo "<tr bgcolor = \"#eeeeee\">";
	echo "<td width = \"200\" bgcolor = \*#eeeeee\*>";
	echo "<div align = \"right\">Gender:</div>";
	echo "</td>";
	echo "<td width = \"200\">".$Gender."</td>";
	echo "</tr>";
	echo "<tr bgcolor = \"#eeeeee\">";
	echo "<td width = \"200\" bgcolor = \*#eeeeee\*>";
	echo "<div align = \"right\">Phone Number:</div>";
	echo "</td>";
	echo "<td width = \"200\">".$PhoneNum."</td>";
	echo "</tr>";
	echo "<tr bgcolor = \"#eeeeee\">";
	echo "<td width = \"200\" bgcolor = \*#eeeeee\*>";
	echo "<div align = \"right\">Date Join:</div>";
	echo "</td>";
	echo "<td width = \"200\">".$DateJoin."</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td colspan = \"2\" bgcolor = \"#dddddd\">&nbsp;</td>";
	echo "</tr>";
	echo "</table>";
}
?>

</body>
</html>

when i click the submit button on the ReadID.htm, the displayform.php should display the information about the "ID" that i want to update..but it doesnt work..and i've also got a prob to update my data..
can u guys solve my prob..im just a beginner in php..plz help me..=(

Edited by nurul_208: n/a

Attachments displayform.png 112.48 KB ReadID.png 94.83 KB
3
Contributors
3
Replies
17
Views
7 Years
Discussion Span
Last Post by nurul_208
0

On line 43 of displayform you do $id = $_GET['id']; yet the DocID (the name of the input field in the first form) gets POST'ed by the form. So it should read: $id = $_POST['DocID'];

Edited by pritaeas: n/a

0

yes pritaeas is right you have to put $id = $_POST, in place on $id=$_GET,

not sure what is this id $_GET,

also try to run the query in phpmyadmin so that you conform that your query is working or not

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.