2017-11-16 3 views
-1

私はURLの最後にセルの値を持ってきて、MYSQLテーブルから目的の行をそれぞれ削除しようとしています。ただし、$row['waybill_ID']の値は期待どおりに反映されません。これを改善するために私は何ができますか?私はこれが少し引き出されていることを理解していますが、私はこれを「あなたは確信していますか?PHP echo MYSQLの値をURLに

<html> 
<body> 

<div id="myNav" class="overlay"> 
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times; 
</a> 
<div class="overlay-content"> 
<h2 style="color: white">Are you sure you want to delete this record?</h2> 
<h2 style="color: white">This record will no longer exist after 
deletion</h2> 
<a id="deletePrompt" href="#" target="blank">Delete Record</a> 
</div> 
</div> 

<div class="midA"> 
    <div class='wrapper'> 
     <button class="accordion">Unit(s) and Driver(s)</button> 
     <div class="panel"> 
      <div class='buffer'> 
     <?php 

     //Unitboard Display 
     $issue_ID = $_GET['idx']; 
     $mysqli = new mysqli('localhost', 'root', '', 'disolDemo'); 
     $query = $mysqli->query("SELECT * FROM unitboard WHERE issue_ID = '$issue_ID'") or die($msqli->error); 
        echo" 
     <table border= 1px solid white> 
     <tr> 
      <th>Action</th> 
      <th>Waybill_ID</th> 
      <th>Driver</th> 
      <th>Unit Type</th> 
      <th>Move Type</th> 
      <th>Route ID</th> 
      <th>Tractor Number</th> 
      <th>Trailer Number</th> 
      <th>Waybill Status</th> 
     </tr> 
     <tr>";?><?php 
     while($row = mysqli_fetch_assoc($query)){?> 
     <td> 
      <a href="#" onclick="window.open('editUnitBoard.php?idx=<?php echo $row['waybill_ID'] ?>', 'name', 'location=no,scrollbars=yes,status=no,toolbar=no,resizable=no')">edit</a>  
      <a href="#" onclick="openNav()">delete</a> 
     </td> 
     <?php echo" 
      <td>{$row['waybill_ID']}</td> 
      <td>{$row['driver']}</td> 
      <td>{$row['unitType']}</td> 
      <td>{$row['moveType']}</td> 
      <td>{$row['location_ID']}</td> 
      <td>{$row['tractorNum']}</td> 
      <td>{$row['trailerNum']}</td> 
      <td>{$row['waybillStatus']}</td> 
     </tr>"; 
     } 
     echo'<table></table>'; 

     ?> 

      <button style="margin-top: 15px; float: right" class='button' type="button" a href="#" onclick="window.open('formNewUnit.php?idx=<?php echo $_GET['idx'] ?>', 'name', 'location=no,scrollbars=yes,status=no,toolbar=no,resizable=no')">Create New Unit</button> 

      <a href="viewRun.php?idx=<?php echo $_GET['idx'] ?>" target="_blank">view</a> 

      <div style="clear: both;"></div> 
      </div> 
     </div> 
    </div> 
</div> 

<script> 
function openNav() { 
document.getElementById("myNav").style.width = "100%"; 
document.getElementById("deletePrompt").href="editUnitBoard.php?idx=<?php 
echo $row['waybill_ID']; ?>"; 
return false; 
} 

function closeNav() { 
document.getElementById("myNav").style.width = "0%"; 
} 
</script> 

</body> 
</html> 

結果がeditUnitBoard.php?IDX =であるが、私は、これはIDを入力しますecho $値を使用して、列を選択し、助け

+0

echo $ row ['waybill_ID'];おそらく?その行方不明。 PHPの終わりをオフにします。 – FreudianSlip

+1

$ row – symcbean

+1

を読み込むコードには何もありません。この値 '$ row ['waybill_ID']'をどこから取得していますか。 ?データベースからフェッチしていますか?そのPHPコードを貼り付けます。 – Raghav

答えて

0

・ホープ例えば何かのリンクeditUnitBoard.php?ID = 1234を必要とします[0] ['列名'];

SQLインジェクションの証明ではないと思います。

 $this->db_connection = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
     $query = mysqli_query($this->db_connection,"SELECT value FROM settings WHERE id='1'"); 
     $value = mysqli_fetch_all($query,MYSQLI_ASSOC); 
+0

申し訳ありません、luuktap-私はこの質問に対して明確ではありませんでした。私は上記の完全なコードを参照のために含めました。 – aglowacki

0

以下のコードは私が探していたものです。あなたのすべての時間をありがとう!

 $testro = $row['driver']; 
     $mysqli2 = new mysqli('localhost', 'root', '', 'disolDemo'); 
     $query2 = " SELECT 
      unitboard.driver, 
      unitboard.officeLocation, 
      trackingboard.issue_ID, 
      unitboard.waybill_ID, 
      unitboard.arrivalDateTimeDest, 
      unitboard.unitType, 
      unitboard.totalMiles, 
      unitboard.waybillStatus, 
      unitboard.moveType, 
      trackingboard.customer 

     FROM trackingboard INNER JOIN unitboard ON trackingboard.issue_ID = unitboard.issue_ID WHERE driver = '$testro'";