This is the code that I am using to perform the required functions spoken about.
mysql_select_db("altura");
$sql = "select * from directory where pno like '%".$pno."%'";
$result = mysql_query($sql);
//$num_results = mysql_num_rows($result);
//for($i=0; $i <$num_results; $i++)
while($i = mysql_fetch_row($result))
{
echo $i[3];?>
<form action='uconfirm.php' method='post'>
<p>Update Employee Information</p>
<p> Last Name
<input type=text size=40 name=lname value=<?=$i[0]?>>
<br><BR>
First Name
<input type=text size=40 name=fname value=<?=$i[1]?>>
<br><BR>
Branch
<input type=text size=40 name=region value=<?=$i[2]?>>
<br><BR>
Title
<input type=text size=40 value=<?=$i[3]?>>
<br><BR>
<input type=submit value=Update></p></form></body>
</html>
<?
}
?>
mysql_fetch_row problem code
Moderator: General Moderators
- thomas777neo
- Forum Contributor
- Posts: 214
- Joined: Mon Mar 10, 2003 6:12 am
- Location: Johannesburg,South Africa
Try this one out
Code: Select all
<?
mysql_select_db("altura");
$sql = "select * from directory where pno like '%".$pno."%'";//could return more than one result, but we will presume it will only return 1 value(Try and be more specific in the select, rather use the employees id)
$result = mysql_query($sql);
$i=0;
$employeeї0]ї"numrows"]=mysql_num_rows($result);
while ($employeeї0]ї"numrows"]>$i){
$employeeї$i]ї"lname"]=mysql_result($result,$i,"lname");//lname = database column name
$employeeї$i]ї"fname"]=mysql_result($result,$i,"fname");
$employeeї$i]ї"region"]=mysql_result($result,$i,"region");
$employeeї$i]ї"title"]=mysql_result($result,$i,"title");
?>
<p> Last Name
<input type="text" size=40 name="lname" value="<? echo $employeeї$i]ї"lname"]; ?>">
<br><BR>
First Name
<input type="text" size=40 name="fname" value="<? echo $employeeї$i]ї"fname"]; ?>">
<br><BR>
Branch
<input type="text" size=40 name="region" value="<? echo $employeeї$i]ї"region"]; ?>">
<br><BR>
Title
<input type="text" size=40 name="title" value="<? echo $employeeї$i]ї"title"]; ?>">
<br><BR>
<input type=submit value=Update></p>
<?
$i++;
}
?>
</form></body>
</html>