【问题标题】:select data from DB to html table and link to an other page (<a>)从 DB 中选择数据到 html 表并链接到其他页面 (<a>)
【发布时间】:2017-10-03 20:39:09
【问题描述】:

在表格中我想要链接 a 当单击转到其他页面并选择此类别中的所有产品时 我想放一个,但我不知道怎么做,因为从数据库中选择的 td 可以是多个

$sql = 'SELECT categorie.id,name,username FROM categorie,user
        where user.id = categorie.added_by ';
$result = $mysqli->query($sql);
?>

<table class="data-table">
    <h1>Categorie List<h1>
    <thead>
        <tr>
            <th>Id</th>
            <th>Username</th>
            <th>Added By</th>
        </tr>
    </thead>
    <tbody>
        <?php
        if($result ==  false)echo "errrrr";
        else{
            while ($row = mysqli_fetch_array($result))
            {
                echo '<tr>
                <td>'.$row['id'].'</td>
                // here i want link <a> when click go to other page and 
                // select all products in this categorie
                <td>'.$row['name'].'</td>
                <td>'.$row['username'].'</td>

                </tr>';

            }
        }
        ?>
    </tbody>
</table>

在表格中我想要链接一个当点击转到其他页面并选择该类别中的所有产品时

【问题讨论】:

    标签: php html mysql mysqli


    【解决方案1】:

    你的链接应该是这样的:

    ...
    <td><a href="otherpage.php?categorie='.$row['id'].'">'.$row['name'].'</a></td>
    ...
    

    然后在otherpage.php中,可以从$_GET['categorie']获取分类ID。

    【讨论】:

      猜你喜欢
      • 2018-07-11
      • 2011-11-03
      • 2016-02-13
      • 2014-01-20
      • 1970-01-01
      • 1970-01-01
      • 2016-07-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多