dongqian1893 2014-04-30 15:26
浏览 13
已采纳

在php中的表中显示数量字段

I'm trying to get my table to look like this

http://gyazo.com/6a134b723c30e97fa99559158cde4b1e

but when I use my code looks like this

http://gyazo.com/1c08f83e744b3a20c99b55eee5313045

I can't get the quantity field or add field to work for the life of me; the quantity field is just blank. I would greatly appreciate some help because I can't get it to work.

            <?php require_once("include/db_connect.php"); ?>
            <html>
            <head><title>Displaying Image files using PHP</title></head>
            <body>
            <h1>Displaying Images from an Image table using PHP</h1>

            <?php


            $db_link = db_connect("project");

            // Retrieve table properties

            $fields = mysql_list_fields("project", "bookstore");
            $num_columns = mysql_num_fields($fields);

            // Make a simple database query to select all columns and rows

            $query = "SELECT * FROM bookstore";
            $result = mysql_query($query) or die("SQL query failed");

            // Display results as an HTML table. Note how mysql_field name
            // uses the $fields object to extract the column names

            echo '<table border="1" cellpadding = "5" >';

            // Display the column names

            echo "<tr>";
            for ($i = 0; $i < $num_columns; $i++)
            {
               echo "<th>", mysql_field_name($fields, $i), "</th>";
            }

                  echo "<th>"Quantity "</th>";

            echo "</tr>";

            // Loop over the rows of the table.
            // $row contains the information for each row
            // Refer to the names of the fields in the table
            // Must ahow the path where the image files are held

            while ($row = mysql_fetch_assoc($result))
            {
               echo "<tr>
               <form action='somethingToHandleForm.php' method='post'>";

               echo "<td>". $row['isbn']. "</td>";
               echo "<td>". $row['title']."</td>";
               echo "<td>". $row['author']."</td>";
               echo "<td>". $row['pub']."</td>";
               echo "<td>". $row['year']."</td>";
               echo "<td>". $row['price']."</td>";
               echo "<td><input type='text' name='quantity' value=".$row['quantity']."/></td>";
               echo "<td><input type='submit' value='add></td>";
               echo "</form>";

               echo "</tr>";

            }
            echo "</table>";

            // Free the resources and close the connection

            mysql_free_result($result);
            mysql_close($db_link);
            ?>
            </body>
            </html>
  • 写回答

2条回答 默认 最新

  • doujing4555 2014-04-30 15:35
    关注

    One thing I noticed is you're missing a single quote in this line after value=add:

    <input type='submit' value='add>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)