由于格式化,提交按钮无法工作

Submit button not working because of formating

本文关键字:工作 按钮 提交 格式化      更新时间:2023-09-26

我已经努力让这个代码工作了一段时间,最后通过一起实现两个代码使它工作起来。只是它的格式不允许我的提交按钮工作。我的提交按钮通过更新sql数据库中文本框中输入的所有数据来进行保存。所以这个按钮是绝对必要的。请告诉我我做错了什么。

<?php
mysql_connect("localhost", "username", "password")or die("cannot connect"); 
mysql_select_db("databas")or die("cannot bselect DB"); 

$sql="SELECT * FROM test"; 
$result=mysql_query($sql); 
// Count table rows 
$count=mysql_num_rows($result); 
?> 
<html>
<head>
    <link rel="shortcut icon" href="../../favicon.ico">
    <link rel="stylesheet" type="text/css" href="css/normalize.css" />
    <link rel="stylesheet" type="text/css" href="css/styles.css" />
    <link rel="stylesheet" type="text/css" href="css/component.css" />
<script src="javafile.js"></script>
    </head>
    <body>
        <div class="component">
            <table class="overflow-y">
                <thead>
                    <tr>
<th width="16%" align="center"  id="box_header2" style='width:10%'><button class="logout"><a href="../login.php?status=loggedout">Log out</a></button>&nbsp;&nbsp;&nbsp;Name</th>
<th width="16%" align="center" id="box_header2" style='width:10%'>Job Code</th>
<th width="16%" align="center"  id="box_header2" style='width:10%'>Date</th>
<th width="14%" align="center" id="box_header2" style='width:20%'>Address</th>
</tr>
</thead>
<tbody>
<tr>
<?php 
while($rows=mysql_fetch_array($result)){ 
?> 
<form action="update3.php" method="post" name="form1">
<tbody>
<tr> 
<th>
<input name="name[]" type="text" id="Name" value="<? echo $rows['Name'];?>">
</th>
<td>
<input name="job[]" type="text" id="Job" value="<? echo $rows['Job']; ?>">
</td>
<td>
<input name="date[]" type="text" id="Date" value="<? echo $rows['Date']; ?>">
</td>
<td>
<input name="address[]" type="text" id="Address" value="<? echo $rows['Address']; ?>">
</td>
<td>
<input name="id[]" type="hidden" value="<? echo $rows['ID']; ?>">
</td> 
</tr> 
</tbody>
<?php 
} 
?> 
<tr> 
</tr>
</tbody>
<tbody>
<tr>  
<td>
<input type="submit" name="Submit" value="Save">
</td>
</tr> 
</tbody>
</table> 
</td> 
</tr> 
</form> 
</table> 
<?php 
mysql_close();  
?> 

试试这个希望它对你有用:

<input name="name[]" type="text" id="Name" value='<?php echo $rows["uname"];?>'>

请将<form>标记放在while循环之前,否则打开的表单将与查询结果集中的行一样多。