0

为什么我的输出不会更新似乎是问题所在?抱歉,我是 php 新手

Childs Name:<?php
    $name= mysql_query("select * from persons ORDER BY name");

echo '<select name="name" id="user" class="textfield1">';
 while($res= mysql_fetch_assoc($name))
{
echo '<option value="'.$res['id'].'">';
echo $res['name'];
echo'</option>';
}

echo'</select>';
?>
</div>
<br />
<div style="margin-left: 97px;">information:
  <input name="name" type="text" value="" /></div>
<div style="margin-left: 127px; margin-top: 14px;"><input name="" type="submit" value="Update" /></div>

我的桌子

<div class="content" id="registry"><br><br>
<table width="100%">
<tr class="head">
<th>Date of entry</th>

<th>Date of Baptisim</th>
<th>Name of the Child</th>

<th>Birthday</th>
<th>Mother</th>
<th>Father</th>
<th>Mother's Address</th>
<th>Father's Address</th>
<th>Current Address</th>
<th>Ninong/Ninang</th>

<th>Amount Paid</th>
<th>Priest</th>
</tr>
<?php

$sql=mysql_query("select * from persons ORDER BY name");
$i=1;
while($row=mysql_fetch_array($sql))
{
$da=$row['da']; 
$entry=$row['entry'];
$name=$row['name'];

$bday=$row['bday'];
$mot=$row['mot'];
$fat=$row['fat'];
$motadd=$row['motadd'];
$fatadd=$row['fatadd'];
$ca=$row['ca'];
$nn=$row['nn'];
$paid=$row['paid'];
$priest=$row['priest'];
if($i%2)

{
?>
<tr id="<?php echo $id; ?>" class="edit_tr">
<?php } else { ?>
<tr id="<?php echo $id; ?>" bgcolor="#f2f2f2" class="edit_tr">
<?php } ?>
<td class="edit_td">
<span class="text"><?php echo $da; ?></span> 
</td>

<td>
<span class="text"><?php echo $entry; ?></span>
</td>

<td>
<span class="text"><?php echo $name; ?></span>
</td>
<td>
<span class="text"><?php echo $bday; ?></span>
</td>
<td>
<span class="text"><?php echo $mot; ?></span>
</td>
<td>
<span class="text"><?php echo $fat; ?></span>
</td>
<td>
<span class="text"><?php echo $motadd; ?></span>
</td>
<td>
<span class="text"><?php echo $fatadd; ?></span>
</td>
<td>
<span class="text"><?php echo $ca; ?></span>
</td>
<td>
<span class="text"><?php echo $nn; ?></span>
</td>

<td>
<span class="text"><?php echo $paid; ?></span>
</td>
<td>
<span class="text"><?php echo $priest; ?></span>
</td>
</tr>

<?php
$i++;
}
?>

</table>
4

1 回答 1

0

至少可以说您的代码很奇怪,从外观上看,您有一个提交输入和一个名称输入,但这并没有在任何地方提交..首先您想要一个表单发布到example.php

<form action="example.php" method="post">
    Name: <input type="text" name="name"><br>
    E-mail: <input type="text" name="email"><br>
    <input type="submit">
</form>

然后example.php你会想要使用表单中的数据运行更新查询:

$sql = "UPDATE mytable SET value = '{$value}' WHERE id = {$id}";

我建议您在此处查找有关如何使用 php 进行更新的教程

于 2013-10-29T15:39:54.647 回答