簡體   English   中英

如何從php創建的表中獲取所選單元格的值?

[英]How can get the value of the selected cell from a table created by php?

使用PHP打印這些值后,我很困惑如何獲取選定單元格的值。

<div>
    <php
       $query = mysql_query(select * from items, $conn);
       echo "<table border='1'>
             <th width ='120'>itemID</th>
             <th width ='120'>itemName</th>";
       while(row = mysql_fetch_array($query))
       {
          echo "<tr>";
          echo "<td>".$row['itemID']."</td>";
          echo "<td>".$row['itemName']."</td>";
       }
       echo "</table>";
    ?>
</div>

看來您做得不錯,我只是編輯了一些錯字,添加了標簽,然后更改為“ mysql_fetch_assoc”函數。 嘗試這個:

<div>
<?php
    $query = mysql_query("select * from items", $conn);
    echo "<table border='1'>
             <tr>
                 <th width ='120'>itemID</th>
                 <th width ='120'>itemName</th>
             </tr>";
    while($row = mysql_fetch_assoc($query))
    {
         echo "<tr>";
         echo "<td>".$row['itemID']."</td>";
         echo "<td>".$row['itemName']."</td>";
         echo "</tr>";
     }
     echo "</table>";
?>
</div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM