由于格式化,提交按钮不起作用

时间:2014-09-26 16:37:21

标签: javascript php sql arrays

我一直在努力让这段代码工作一段时间,最后通过一起实现两个代码来实现它。除了格式化它不会让我的提交按钮工作。我的提交按钮通过更新在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();  
?> 

2 个答案:

答案 0 :(得分:0)

试试这个希望它适合你:

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

答案 1 :(得分:0)

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