2017-04-25 5 views
-3

이 당신이 볼 수 있듯이 나는 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를 수집하도록 도와주세요.

+0

확실하지 무엇을'SelectionId = ' "$ 캐리어"..'; "'할 생각입니다 당신이에 ID를 추가하려면?. 문자열 인 경우 PHP 블록을 추가해야합니다 :''UpdateStudent.php? SelectionId = "'(PHP 101입니다.) 그게 문제가 아니라면, 당신의 질문을 명확히 할 필요가 있습니다. –

+0

어디에서'$ _GET [ 'SelectedId']'를 얻을 것입니까? – Swellar

+0

'$ _GET [ 'SelectedId']'가 코드에 없기 때문에'$ Carrier'는 결코 값을 갖지 않을 것입니다. – Swellar

답변

0

난 당신이 이런 식으로 의미 생각 :

<a href="UpdateStudent.php?SelectionId=<?php echo $Carrier ;?>"> 
    <img src="sawiro/EditImage.jpg" alt="Edit Student Image"/> 
</a> 
+0

아직 해결되지 않았습니다. –

+0

@MohamedAbdullahiSalah - 도움을 더 원하면 더 많은 정보를 제공해야합니다. _ 아직 해결되지 않았다는 것은 무엇을 의미합니까? 오류 메시지가 있습니까? 무슨 일이야? 예상되는 결과는 무엇입니까? 이 솔루션이 작동하지 않습니까 아니면 다른 것입니까? –

+0

@MagnusEriksson - 치료 결과가 너무 길어서 여기에 게시 할 수 없습니다. 그런데 대상에있는 ID를 수집하여 다른 PHP에서 특정 행을 업데이트하는 데 사용하고 싶습니다. –