Php 无法将Mysql表中的所有数据存储到新的html表单中。
在这里,我面临着while循环的问题。。(我想)无法将我的所有数据从Mysql表存储到我的html表单中 由于while循环中重复了相同的name元素,第一行仅被过帐,其余行未过帐 这里是$_POST['mechanical_name'];有一次我用。。这个有什么问题吗。。 因为这不是一个while循环,或者如果您认为下面的代码有任何其他问题,请给出建议Php 无法将Mysql表中的所有数据存储到新的html表单中。,php,Php,在这里,我面临着while循环的问题。。(我想)无法将我的所有数据从Mysql表存储到我的html表单中 由于while循环中重复了相同的name元素,第一行仅被过帐,其余行未过帐 这里是$_POST['mechanical_name'];有一次我用。。这个有什么问题吗。。 因为这不是一个while循环,或者如果您认为下面的代码有任何其他问题,请给出建议 嗯 您的文本输入具有相同的静态名称 如果要将其保存为以下格式,则应为其指定一个数组名称: <input type="text" na
嗯
您的文本输入具有相同的静态名称
如果要将其保存为以下格式,则应为其指定一个数组名称:
<input type="text" name="mechanic_ID[]" value="first_one" />
<input type="text" name="mechanic_ID[]" value="second_one" />
and when get data
$mechanic_ids = $_POST['mechanic_ID'];
// this give you data in array ('first_one','second_one')
can resume
foreach($mechanic_ids as $mechanic_id){
// do some thing in this one
}
什么时候得到数据
$mechanical\u ID=$\u POST['mechanical\u ID'];
//这将为您提供数组中的数据('first_-one','second_-one'))
可以恢复
foreach($mechanical\u id作为$mechanical\u id){
//在这件事上做点什么
}
这里是关于
机修工Id
机械师姓名
工作日选择
删除用户
这里是Mechanical表的所有数据(mechanic_ID,Mechanical_name)可以检索的内容,它显示了所有数据;因为while循环,但是当注册它时,第一行只能发布,其余行不能发布。是的,@Homan Alhaytham,很好,谢谢。。但从值开始,我是从一个表的数据行“code”value=“所以我们不能添加“first\u one”“second\u one”是吗..?它将从一个表加载。我测试了数组函数,但out value=“它正在工作,但我需要从一个表中检索数据时,数据能够存储到另一个表中。(它使用下拉菜单)但我需要一个粗体的表格格式,这里我是来自“机械表”的回显数据,然后将其存储到“时间表表”中
<div>
<form role="form" method="post" action="schedule.php">
<table class="table table table-inverse table-hover">
<fieldset>
<div>
<input class="form-control" placeholder="Username" name="month" type="Month" value="January">
</div>
<thead class="thead-inverse">
<tr>
<th>Mechanic Id</th>
<th>Mechanic Name</th>
<th>Woking Day Selection</th>
<th>Delete User</th>
</tr>
</thead>
<?php
include("db_conection.php");
$view_users_query="select * from mechanic";//select query for viewing users.
$run=mysqli_query($dbcon,$view_users_query);//here run the sql query.
while($row=mysqli_fetch_array($run))//while look to fetch the result and store in a array $row.
{
$mechanic_ID=$row[0];
$mechanic_name=$row[1];
?>
<tr>
<td>
<input name="mechanic_ID" type="text" value="<?php echo $mechanic_ID; ?>">
</td>
<td>
<input name="mechanic_name" type="text" value="<?php echo $mechanic_name; ?>">
</td>
<td>
<div class="weekDays-selector">
<input type="checkbox" name="Sun" id="weekday-sun" class="weekday" />
<label for="weekday-sun">S</label>
<input type="checkbox" name="Mon" id="weekday-mon" class="weekday" />
<label for="weekday-mon">M</label>
<input type="checkbox" name="Tue" id="weekday-tue" class="weekday" />
<label for="weekday-tue">T</label>
<input type="checkbox" name="Wed" id="weekday-wed" class="weekday" />
<label for="weekday-wed">W</label>
<input type="checkbox" name="Thu" id="weekday-thu" class="weekday" />
<label for="weekday-thu">T</label>
<input type="checkbox" name="Fri" id="weekday-fri" class="weekday" />
<label for="weekday-fri">F</label>
<input type="checkbox" name="Sat" id="weekday-sat" class="weekday" />
<label for="weekday-sat">S</label>
</div>
</td>
<td>
<!--button-->
<input class="btn btn-lg btn-success btn-block" type="submit" value="register" name="register" >
</td>
</tr>
</fieldset>
<?php } ?>
</table>
</form>
</div>
<?php
include("db_conection.php");//make connection here
if(isset($_POST['register']))
{
$mechanic_ID=$_POST['mechanic_ID'];//here getting result from the post array after submitting the form.
$mechanic_name=$_POST['mechanic_name'];//same
$month=$_POST['month'];//same
$Sun=$_POST['Sun'];//same
$Mon=$_POST['Mon'];//same
$Tue=$_POST['Tue'];//same
$Wed=$_POST['Wed'];//same
$Thu=$_POST['Thu'];//same
$Fri=$_POST['Fri'];//same
$Sat=$_POST['Sat'];//same
if($mechanic_name=='')
{
//javascript use for input checking
echo"<script>alert('Please enter the name')</script>";
exit();//this use if first is not work then other will not show
}
//insert the user into the database.
$insert_schedule="insert into schedule (mechanic_ID,mechanic_Name,month,Sun,Mon,Tue,Wed,Thu,Fri,Sat) VALUE ('$mechanic_ID','$mechanic_name','$month','$Sun','$Mon','$Tue','$Wed','$Thu','$Fri','$Sat')";
if(mysqli_query($dbcon,$insert_schedule))
{
echo"<script>window.open('index.html','_self')</script>";
}
}
?>