我创建了从注册页面获取数据的页面。每个获取数据都包含添加按钮。我执行另一个sql查询,该查询插入了单击该添加按钮的人员的详细信息。现在,在成功添加之后,我希望它在单击的特定行ID上回显。我尝试这样做,但它在所有行上都回显。我希望开发人员可以帮助我 下面我附上代码。
<?php
session_start();
$mysqli=new MySQLi('127.0.0.1','root','','learning_malaysia');
$sql = "SELECT * FROM tutor_register INNER JOIN tutorskill ON tutor_register.register_ID = tutorskill.register_ID";
$result= mysqli_query($mysqli,$sql);
$_SESSION['mes']='';
?>
<html>
<body>
<?php
if(mysqli_num_rows($result)>0)
{
while($row = mysqli_fetch_array($result))
{
$register_ID=$row["register_ID"];
$username = $row['username'];
$profile = $row['profile'];
$email = $row['email'];
$address=$row['address'];
$gender=$row['gender'];
$main_subject=$row["main_subject"];
$subject_add=$row["subject_add"];
$rate_main=$row["rate_main"];
$rate_add=$row["rate_add"];
$qualification=$row["qualification"];
?>
<table><form method="post">
<tr class="border_bottom">
<td height="230"><img src='<?php echo $profile;?>'width="200" height="200"/> </td><td><td></td></td>
<td class="data" width="800"><strong>Username:</strong> <?php echo $username;?></br>
<strong>Address:</strong> <?php echo $address;?></br>
<strong>Gender:</strong><?php echo $gender;?></br>
<strong>Main Subject:</strong><?php echo $main_subject ;?></br>
<strong>Subject Added: </strong><?php echo $subject_add;?></br>
<strong>Main Subject Rate:</strong> <?php echo $rate_main;?></br>
<strong> Added Subject Rate:</strong><?php echo $rate_add; ?></br>
<strong>Qualification:</strong> <?php echo $qualification; ?></td>
<?php
if(isset($_POST['subject']) and $_POST['id']) {
$user_id = $_SESSION['sid'];
$friend_id = $_POST['id'];
$status = "yes";
$subject=$_POST['subject'];
$sql="INSERT INTO friends(user_id,status,subject,friend_id)" ."VALUES('$user_id','yes','$subject','$friend_id') ";
if($mysqli->query($sql)=== true) {
$_SESSION['status']="yes";
$_SESSION['mes']="sent";
$_SESSION['user_id'] = $user_id;
} else {
}
}?>
<form method="post" id="form" enctype="multipart/form-data" autocomplete="off" >
<input type="hidden" name="id" value="<?php echo $row['register_ID'];?>" />
<td>
<input type="hidden" id="subject" name="subject" data-uid=<?php echo $_SESSION['sid'] ;?>/>
<input type="hidden" value="" />
<div><?php echo $_SESSION['mes'];?></div>
<input type="submit" name="addfriend" data-type='addfriend' id="add" class="btn" value="add"
onclick="return myFunction(this.form)" />
<input type="submit" value="unfriend" id="btn" onclick="unfriend(form);" disabled class="btn"/> </td> </form>
</tr></form></form>
</div>
<?php
}
}
?>
<td> <div> </td></table>
</body>
</html>