2013-06-16 3 views
-1

내 질문에 대한 답변을 찾고 있었지만 하나도 찾을 수 없었습니다.데이터베이스에서 검색된 입력 필드에서 데이터를 업데이트하는 방법은 무엇입니까?

db에서 입력 필드로 데이터를 검색하고 입력 필드의 변경 값을 db로 다시 업데이트하고 있습니다.

가 여기 내 코드

는 A 링크
echo "<table>"; 
while ($row = mysql_fetch_array($result)){ 
echo "<form method=\"GET\" action=\" ".htmlspecialchars($_SERVER['PHP_SELF'])."\" > "; 
echo "<tr><td>ID:</td><td>Company Name</td><td>Date for Service</td><td>Edit</td><td>Delete</td></tr>"; 
echo "<td><input type= 'text' name = 'jobrequestnumber' value =".$row['jobrequestnumber']."></td>" ; // results in the same jobrequestnumbers 
echo "<td><input type= 'text' name = 'requestingcompany' value =".$row['requestingcompany']."></td>" ;//this too 
echo "<td><input type= 'date' name = 'dateforService' value =".$row['dateforService']."></td>" ;// this one also 
echo "<td><a href='delete.php?jobrequestnumber=".$row['jobrequestnumber']."'>Delete</a></td>"; //too 
echo "</form> "; 
echo "<td><a href=\"update_request.php?jobrequestnumber='jobrequestnumber'&requestingcompany='requestingcompany'&dateforService='dateforService'\">Update</a></td>"; 
echo "</tr>"; 
} 
echo "</table>"; 

이다, 내가 입력 필드의 이름을 참조하여 값을 전달하려고하지만, 그것은 작동하지 않습니다.!

다른 방법이나 다른 사람이이를 해결할 수 있습니까?

대단히 감사합니다.

+1

이것의 목적은 무엇인가를는 mysql_fetch_array하지? –

+0

귀하의 HTML 코드가 유효하지 않습니다. ''은 (는) ''의 하위 여야합니다. '

'을' '과' '사이에 넣을 수 있는지 확신 할 수 없습니다. 브라우저는 양식이 시작되는 위치와 끝나는 위치를 모르기 때문에 첫 번째 양식을 제출합니다. –

+0

의 위치에 관계없이 정상적으로 작동합니다. – Giantrain

답변

1

사용 후 대신 얻을

echo "<table>"; 
echo "<tr><td>ID:</td><td>Company Name</td><td>Date for Service</td><td>Edit</td><td>Delete</td></tr>"; 

while ($row = mysql_fetch_array($result)){ 
echo "<form method=\"post\" action=\" ".htmlspecialchars($_SERVER['PHP_SELF'])."\" > 
<input name=\"id\" type=\"hidden\" value=\"".$row['jobrequestnumber']."\"> 
"; // added hidden id for update 


echo "<td><input type= 'text' name = 'jobrequestnumber' value =".$row['jobrequestnumber']."></td>" ; // results in the same jobrequestnumbers 
echo "<td><input type= 'text' name = 'requestingcompany' value =".$row['requestingcompany']."></td>" ;//this too 
echo "<td><input type= 'date' name = 'dateforService' value =".$row['dateforService']."></td>" ;// this one also 
echo "<td><a href='delete.php?jobrequestnumber=".$row['jobrequestnumber']."'>Delete</a></td>"; //too 
echo " "; 
echo "<td><input name=\"update\" type=\"submit\" value=\"update\"></td>"; 
echo "</tr></form>"; 
} 
echo "</table>"; 
+0

과 같은 값이됩니다. 한 필드와 일치하는 이름이 하나만 필요하지 않습니까? 여러 필드가 있고 이름이 반복됩니다. – Giantrain

+0

무엇? 어떤 필드는 하나의 일치 필드가 필요한 멀티입니다. 어쩌면 당신이 원하는 데이터의 예입니다. – amigura

+0

그래서 while 루프를 사용할 때 위의 코드는 각각 하나 이상의 필드를 생성합니다

Giantrain

0
당신은 mysql_fetch_assoc를 사용할 필요가

()

+1

이 경우 – Giantrain

관련 문제