【发布时间】:2021-04-25 22:46:47
【问题描述】:
所以问题是为什么即使单击第二行的编辑按钮,我也只获得第一行数据,而相同的请求结果将数据正确显示到我的 html 表行中。
我的目标是将我在 html 表格行中获得的相同数据显示到弹出表单输入中,然后编辑/更新相同的数据并将新版本的数据再次发送到数据库中......任何帮助甚至一个想法都是太好了,提前感谢。
Photo
<?php
$host = "localhost"; //IP of your database
$userName = "root"; //Username for database login
$userPass = ""; //Password associated with the username
$database = "database_name"; //Your database name
$connectQuery = mysqli_connect($host,$userName,$userPass,$database);
if(mysqli_connect_errno()){
echo mysqli_connect_error();
exit();
}else{
$selectQuery = "SELECT * FROM `table_name` ORDER BY `ID` ASC";
$result = mysqli_query($connectQuery,$selectQuery);
if(mysqli_num_rows($result) > 0){
}else{
$msg = "No Record found";
}
}?>
<!-- of course starting by a while loop -->
<?php while($row = mysqli_fetch_assoc($result)){?>
<!-- this how i displayed the data in a table row -->
<td><?php echo $row['row_name'];?></td>
<!-- that's how i displayed the data in a pop-up form inputs -->
<input type="number" value="<?php echo $row['row_name'];?>">
【问题讨论】:
-
请注意,这些行只是一些序列,是与我的问题/问题相关的最重要的序列
标签: javascript php html mysql