2013-07-02 7 views
0

저는 아직 초보자입니다. 그리고 저는 이것에 정말로 힘든 시간을 보내고 있습니다. 첫 번째 확인란을 선택하면 내장 된 YouTube 비디오를 페이지에 에코 할 수 있습니까? 도와주세요. 감사.에코 iframe 값의 내부

<form action="" method="post"> 
    <label><input type="checkbox" name="check_list[]" value="<?php echo "<iframe width=\"640\" height=\"360\" src=\"http://www.youtube.com/embed/TnxUOdAhAdk\" frameborder=\"0\" allowfullscreen></iframe>"; ?>">Video1</label> 
    <label><input type="checkbox" name="check_list[]" value="value 2">Video2</label> 
    <label><input type="checkbox" name="check_list[]" value="value 3">Video3</label> 
    <input type="submit" /> 
</form> 


<?php 
if(!empty($_POST['check_list'])) { 
    foreach($_POST['check_list'] as $check) { 
     echo $check; 
    } 
} 
?> 

답변

0

나는 youtube 링크를 이미 알고 있으므로 PHP 대신 javascript/jquery를 사용하는 것이 좋습니다. This link will give you more info about this.

<html> 
<head> 
</head> 
<body> 
    <form action='index.php' method='post'> 
     <input type='checkbox' name='video1' value='true'/>Show Video1 
     <br/> 
     <input type='checkbox' name='video2' value='true'/>Show Video2 
     <br/> 
     <input type='checkbox' name='video3' value='true'/>Show Video3 
     <br/> 
     <input type='submit' value='Show Videos'/> 
    </form> 

    <?php 
    if (isset($_POST['video1'])) { 
     echo "<iframe width=\"640\" height=\"360\" src=\"http://www.youtube.com/embed/TnxUOdAhAdk\" frameborder=\"0\" allowfullscreen></iframe>"; 
     echo "<br/>"; 
     echo "<br/>"; 
    } 
    if (isset($_POST['video2'])) { 
     echo "<iframe width=\"640\" height=\"360\" src=\"http://www.youtube.com/embed/2mKxsC2oi5s\" frameborder=\"0\" allowfullscreen></iframe>"; 
     echo "<br/>"; 
     echo "<br/>"; 
    } 
    if (isset($_POST['video3'])) { 
     echo "<iframe width=\"640\" height=\"360\" src=\"http://www.youtube.com/embed/tC2fjzWIM-Y\" frameborder=\"0\" allowfullscreen></iframe>"; 
     echo "<br/>"; 
     echo "<br/>"; 
    } 
    ?> 
</body> 
</html> 
: 어쨌든 여기

당신에게 도움이 될 수있는 PHP 코드