2016-10-01 9 views
-1

これは、私はこれは、このフォームは私がすることができますテーブルからボタンやモーダルショーやをクリックし、モーダルである第二のコードでボタンの編集テーブル行からどのように値を取得できますか?

$query = "SELECT * FROM tbl_document LIMIT $start, $end"; 
$result = mysqli_query($con,$query); 
echo "<table border='1' width='300' height='160' align = center id='result'>"; 
echo '<tr> 
    <th width="80">ID</th> 
    <th width="200">Title</th> 
    <th width="260">Presented To</th> 
    <th width="260">Presented By</th> 
    <th width="160">Date Submitted</th> 
    <th>Location</th> 
    <th width="17%">Option</th> 
</tr>'; 
while($row = mysqli_fetch_array($result)){ 
    echo "<tr align = center >"; 
    echo "<td width='20' height='60'>" .$row['ID']. "</td>"; 
    echo "<td width='120' height='60'>" .$row['Title']. "</td>"; 
    echo "<td>" .$row['Presented_To']. "</td>"; 
    echo "<td>" .$row['Presented_By']. "</td>"; 
    echo "<td>" .$row['Date_Submitted']. "</td>"; 
    echo "<td>" .$row['Location']. "</td>"; 
    echo "<td width='17%'>"; 
?> 
<p> 
    <button onclick="document.getElementById('edtID').style.display='block'" value="<?php echo $row['ID']; ?>" class="w3-btn w3-blue w3-border-large w3-circle" id="edit" name="edit" style="width:60%"><i class="fa fa-edit"></i>&nbsp;Edit</button> 

を使用して編集する行を選択します表形式で編集しても私のコードが欠けていますか? 2番目のフォーム(モーダル)で

<form method="post" action="<?php $_SERVER['PHP_SELF'];?>"> 
<p> 
<label class="w3-label w3-text-black"><strong>Title:</strong></label> 
<input class="w3-input w3-hover-light-blue w3-animate-input w3-border-large w3-light-grey" style="width:100%" type="text" id="title" name="title" placeholder="Title" value=<?php $row['Title']; ?>required></span> 
</p> 
</form> 
+0

テーブル行のどの値 – RiggsFolly

答えて

0

、私はあなたのタイトル

<form method="post" action="<?php $_SERVER['PHP_SELF'];?>"> 
<p> 
<label class="w3-label w3-text-black"><strong>Title:</strong></label> 
<input class="w3-input w3-hover-light-blue w3-animate-input w3-border-large w3-light-grey" style="width:100%" type="text" id="title" name="title" placeholder="Title" value=<?php echo $row['Title']; ?>required></span> 
</p> 
</form> 

の値を表示するには、no、エコーを見ていない。また、あなたの最初のフォームのために、あなたはそれをこのように書くことができます

<table border='1' width='300' height='160' align=center id='result'> 
    <tr> 
    <th width="80">ID</th> 
     <th width="200">Title</th> 
     ... 
    </tr> 

    <?php 

    while($row = mysqli_fetch_array($result)) 
    { 
     echo "<tr align = center >"; 
     echo "<td width='20' height='60'>" .$row['ID']. "</td>"; 
     echo "<td width='120' height='60'>" .$row['Title']. "</td>"; 
     ... 
    ?> 

    <p> 
     <button onclick="document.getElementById('edtID').style.display='block'" value="<?php echo $row['ID']; ?>" class="w3-btn w3-blue w3-border-large w3-circle" id="edit" name="edit" style="width:60%"> 
     <i class="fa fa-edit"></i>&nbsp;Edit 
     </button> 
    </p> 

    <?php 

    } 

    ?> 

最後に、データベースに関連するすべての作業にPDOを使用するようにしてください。

関連する問題