Ceci est mon tout code html et phpComment collecter l'identifiant une fois que je clique sur la page de mise à jour liée à l'image en 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>
Je veux ajouter Selectionid, comme vous pouvez le voir sur ce
?SelectionId=$Carrier;
où ma variable id est $Carrier
becuase de ce code
if(isset($_GET['SelectedId']))
{$Carrier = clearInput($_GET['SelectedId']);}
Je veux une fois que je clique sur <img src="sawiro/EditImage.jpg" alt="Edit Student Image">
pour me donner l'adresse UpdateStudent.php?SelectionId=8
par exemple, pour utiliser cet identifiant pour la définition de l'objectif des données.
S'il vous plaît aidez-moi à recueillir l'ID de la cible php à utiliser dans un autre php pour mettre à jour cette ligne particulière.
Je ne sais pas ce que 'SelectionId = « « Carrier $ ».. »," 'Est supposé faire si vous voulez ajouter l'ID au?. chaîne, vous devez ajouter un bloc php: "UpdateStudent.php? SelectionId = = $ Carrier?>" '(c'est PHP 101) .Si ce n'est pas le problème, vous devez clarifier vos questions car il est _very_ peu clair ce que vous demandez réellement –
Où obtiendrez-vous '' $ _GET ['SelectedId'] '? – Swellar
' $ Carrier' n'aura jamais de valeur parce que '$ _GET ['SelectedId']' semble manquer dans vos codes – Swellar