이 당신이 볼 수 있듯이 나는 Selectionid를 추가 할 내 모든 HTML과 PHP 코드아이디를 수집하는 방법을 한 번 클릭하면 이미지가 링크 된 업데이트 페이지를 PHP에서 클릭합니까?
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2>Student Details</h2>
<div id="EditStudent">
<a href="UpdateStudent.php?SelectionId=$Carrier"><img src="sawiro/EditImage.jpg" alt="Edit Student Image"></a>
</div>
<table style="width: 100%" border ="0" bordercolor="green" bgcolor="white" cellspacing="20" cellpadding="0">
<thead>
<tr>
<?php
$Carrier = 0;
function clearInput($data){
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if(isset($_GET['SelectedId'])){
$Carrier = clearInput($_GET['SelectedId']);
}
$cnx = new PDO('mysql:host=localhost;dbname=transportsystem;charset=utf8', 'root', '');
$result = $cnx->query("SELECT * FROM person
INNER JOIN student ON person.PerID = student.StPersonID
WHERE PerID = $Carrier");
while($row = $result->fetch()){
$Name = $row["Name"];
$Gender = $row["Gender"];
$Telephone = $row["Telephone"];
$Class = $row["Class"];
echo '<th colspan="8" style="font-size:40px;">'.$row["Name"].'</th>';
}
?>
</tr>
</thead>
<tr style="color: #000;">
<th> Student ID:</th>
<td><?php echo $Carrier;?></td>
</tr>
<tr>
<th> Full Name:</th>
<td><?php echo $Name;?></td>
</tr>
<tr>
<th> Gender:</th>
<td><?php echo $Gender;?></td>
</tr>
<tr>
<th> Telephone:</th>
<td><?php echo $Telephone;?></td>
</tr>
<tr>
<th> Class:</th>
<td><?php echo $Class;?></td>
</tr>
</table>
</body>
</html>
입니다에 내 id 변수이 코드
if(isset($_GET['SelectedId']))
{$Carrier = clearInput($_GET['SelectedId']);}
의 becuase
$Carrier
입니다
?SelectionId=$Carrier;
<img src="sawiro/EditImage.jpg" alt="Edit Student Image">
을 클릭하면 예를 들어 UpdateStudent.php?SelectionId=8
이라는 URL을 입력하고 데이터 ID 설정에이 ID를 사용합니다.
다른 PHP에서 특정 행을 업데이트하는 데 사용하는 대상 PHP에서 ID를 수집하도록 도와주세요.
확실하지 무엇을'SelectionId = ' "$ 캐리어"..'; "'할 생각입니다 당신이에 ID를 추가하려면?. 문자열 인 경우 PHP 블록을 추가해야합니다 :''UpdateStudent.php? SelectionId = = $ Carrier?> "'(PHP 101입니다.) 그게 문제가 아니라면, 당신의 질문을 명확히 할 필요가 있습니다. –
어디에서'$ _GET [ 'SelectedId']'를 얻을 것입니까? – Swellar
'$ _GET [ 'SelectedId']'가 코드에 없기 때문에'$ Carrier'는 결코 값을 갖지 않을 것입니다. – Swellar