我在我的数据库中有一个名为议程表的表,它与另一个称为会议的表链接。我想通过表单编辑议程表,但我希望议程字段中的当前信息显示在Web表单上。无法从数据库中获取数据以显示在通过表单更新的字段中
<?php
include 'library/connect.php';
$agenda_id = $_GET['agenda_id'];
$result = mysql_query("SELECT agenda.*, meetings.meeting_id FROM agenda INNER JOIN meetings ON agenda.meetings = meetings.meeting_id WHERE agenda_id = '$agenda_id'");
$row = mysql_fetch_array($result);
$meeting_id = $row['meeting_id'];
?>
<form id="form1" name="form1" method="post" action="secretary_agendaSuccesful.php?agenda_id=<?php echo $agenda_id; ?>">
<table width="666" border="1">
<tr>
<td width="91">Subject:</td>
<td width="559"><span id="sprytextarea1">
<label for="subject"></label>
<textarea name="subject" id="subject" cols="45" rows="5" value="<? echo $row['subject'] ?>"></textarea>
<span class="textareaRequiredMsg">A subject is required.</span></span></td>
</tr>
<tr>
<td>Duration:</td>
<td><span id="sprytextfield1">
<label for="duration"></label>
<input type="text" name="duration" id="duration" value="<? echo $row['duration'] ?>"/>
<span class="textfieldRequiredMsg">duration in hours</span><span class="textfieldInvalidFormatMsg">Enter duration in hours</span></span></td>
</tr>
<td> </td>
<td><input type="submit" name="submitbtn" id="submitbtn" value="Submit" /></td>
</tr>
</table>
</form>
这是从数据库中获取信息到域中的正确方法吗?
您的代码对SQL注入攻击非常开放。您不应该直接将'$ _GET'变量(或*任何*变量)插入到查询中。请看看这个问题如何解决它,http://stackoverflow.com/questions/60174/best-way-to-stop-sql-injection-in-php – 2012-01-06 22:49:14