รบกวนช่วยดึง id จาก sql ที่ select ออกมาโชว์ทีค่ะ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา รบกวนช่วยดึง id จาก sql ที่ select ออกมาโชว์ทีค่ะ

รบกวนช่วยดึง id จาก sql ที่ select ออกมาโชว์ทีค่ะ
คือการทำงานเป็นแบบนี้ค่ะ รูปแรก เป็นข้อมูลที่ select วนออกมาโชว์ทุกรูป


ส่วนรูปนี้ พอคลิกรูปต้องโชว์ popup รูปที่เลือก แต่ติดปัญหา   คือตอนนี้พอคลิกแล้วมันไม่รู้จะดึงไอดีไหนมาโชว์เลยไม่ขึ้นรุปอะค่ะ หนูเลยไม่รู้ว่าต้องใส่ไอดีตอนดึงจากตรงไหนรบกวนช่วยทีค่ะ



อันนี้เป็นโค้ดทั้งหมดค่ะ
อันแรกดึงรูปมาโชว์
<div id="cv" class="img-responsive img-thumbnail">
                        	<?php
							while($row = mysql_fetch_array($result))
							{
							?>
                        	<button type="button" style="background-color:#fff; border-color:#fff;" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal" >
      							<img src="document/<?=$row['cd_file']?>" />
                                <input type="hidden" value="<?=$row['cd_id']?>">
	                			</button>
                                       <?php
							}
							?>
                           
                            </div>

นี่คือพอคลิกจะมาอยู่ส่วนนี้

 <div class="modal fade" id="myModal" role="dialog">
    							<div class="modal-dialog">
                					<div class="modal-content">
        								<div class="modal-header">
          									<button type="button" class="close" data-dismiss="modal">&times;</button>
          										<h4 class="modal-title">CV</h4>
        								</div>
        								<div class="modal-body">
                        
                        	
          									<p align="center">
                                            <img src="document/<?=$objResult['cd_file']?>" width="300" height="450"/>
                                            </p>
                         
        								</div>
        								<div class="modal-footer">
                                			<a href="Content/download.php?filename=<?php echo $row['cd_file'] ;?>&id=<?=$crews;?>" >
                                            	<button type="button" class="btn btn-success">Download</button>
                                            </a>
          									<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
        								</div>
      								</div>
      							</div>
      						</div>




Thepaysz 183.89.147.xxx 26-10-2015 12:08:36

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
น่าจะต้องใช้เป้น jquery หรือ javascript สร้างฟังก์ชั่นส่งเข้าไป เช่น ตรงปุ่มก่อนแสดง popup ก็สร้าง
 event onclick แล้วกกำหนดฟังก์ชั่น ส่งค่าไป 
สำหรับในส่วนของ popup ก็กำหนด id ให้กับ element ที่เราต้องการ เพื่อนจะได้อ้างอิงเรียกใช้งาน โค้ดรวมๆ  ก็น่าจะประมาณนี้

<div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title" id="place_title">CV</h4>
            </div>
            <div class="modal-body">


            <p align="center">
            <img id="place_picture" src="document/<?=$objResult['cd_file']?>" width="300" height="450"/>
            </p>

            </div>
            <div class="modal-footer">
            <a id="place_download" href="Content/download.php?filename=<?php echo $row['cd_file'] ;?>&id=<?=$crews;?>" >
            <button type="button" class="btn btn-success">Download</button>
            </a>
            <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>




<div id="cv" class="img-responsive img-thumbnail">
<?php
while($row = mysql_fetch_array($result))
{
?>
<button onclick="set_popup('<?=$row['cd_id']?>','<?=$row['cd_file']?>','<?=$row['cd_file']?>')" type="button" style="background-color:#fff; border-color:#fff;" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal" >
<img src="document/<?=$row['cd_file']?>" />
<input type="hidden" value="<?=$row['cd_id']?>">
</button>
       <?php
}
?>



</div>
<script type="text/javascript">
function set_popup(data_title,data_img,data_download){
    $("#place_title").html(data_title);
   $("#place_picture").attr("img","document/"+data_img"");
    $("#place_download").attr("href","Content/download.php?filename=" data_download"");
}
</script>


ninenik 180.183.104.xxx 26-10-2015
 ความคิดเห็นที่ 2
ไม่ได้อ่าค่ะ พี่มีวิธีอื่นแนะนำอีกมั้ยคะ 


thepaysz 183.88.100.xxx 26-10-2015 16:40
 ความคิดเห็นที่ 3


ninenik 180.183.104.xxx 26-10-2015
1






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ