你好,我刚接触编码,但我不知道如何在我的表上添加span我的echo每次继续移动表我需要帮助如何在我的代码上做语法
这是我表格的原始代码
<td><span id="name<?php echo $row['id']; ?>"><?php echo $row['name']; ?></td>
<td><span id="email<?php echo $row['id']; ?>"><?php echo $row['email']; ?></td>
<td><span id="username<?php echo $row['id']; ?>"><?php echo $row['username']; ?></td>
<td><span id="level<?php echo $row['id']; ?>"><?php echo $row['password']; ?></td>
这是我的另一张表,但每次按下按钮都不会在我的编辑中显示任何值
<td>'.$row["name"].'</td>
<td>'.$row["username"].'</td>
<td>'.$row["email"].'</td>
<td>'.$row["level"].'</td>
<td><a style="cursor:pointer;" class="btn btn-info edit" data-id="'.$row['id'].'"><span class="glyphicon glyphicon-edit" aria-hidden="true" ></span></a> || <a style="cursor:pointer;" class="btn btn-danger delete" data-id="'.$row['id'].'"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
我试图获取如何将id放在此echo输出上以将其指向我的按钮,显示id的值将返回该id上的所有值。
while($row = mysqli_fetch_array($result)) {
$output .= '
<tr>
<td>'.$row["name"].'</td> <-- how do i add <span>,put id on this rows
<td>'.$row["username"].'</td> or how to add id on this table
<td>'.$row["email"].'</td>
<td>'.$row["level"].'</td>
<td>
<a style="cursor:pointer;" class="btn btn-info edit" data-id="'.$row['id'].'"><span class="glyphicon glyphicon-edit" aria-hidden="true" ></span></a> || <a style="cursor:pointer;" class="btn btn-danger delete" data-id="'.$row['id'].'"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
</td>
</tr>';
}
echo $output;
}
答案 0 :(得分:0)
这是您的$output
,其中包含<span>
:
$output .= '
<tr>
<td><span id="name'.$row["id"].'">'.$row["name"].'</span></td>
<td><span id="username'.$row["id"].'">'.$row["username"].'</span></td>
<td><span id="email'.$row["id"].'">'.$row["email"].'</span></td>
<td><span id="level'.$row["id"].'">'.$row["level"].'</span></td>
<td>
<a style="cursor:pointer;" class="btn btn-info edit" data-id="'.$row['id'].'"><span class="glyphicon glyphicon-edit" aria-hidden="true" ></span></a> || <a style="cursor:pointer;" class="btn btn-danger delete" data-id="'.$row['id'].'"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
</td>
</tr>';