如何从php创建的表中获取所选单元格的值?

时间:2021-09-02 08:40:13

After I printed those values by using PHP, I got confused how to get the value of a selected cell.

在我使用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>

1 个解决方案

#1


seems you doing fine, iv'e just edited some typos, added tags,and changed to: "mysql_fetch_assoc" function. try this:

看来你做得很好,我只是编辑了一些拼写错误,添加了标签,并改为:“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>

#1


seems you doing fine, iv'e just edited some typos, added tags,and changed to: "mysql_fetch_assoc" function. try this:

看来你做得很好,我只是编辑了一些拼写错误,添加了标签,并改为:“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>