0

艺术家表中有艺术家、曲目等表有: id name cover desc

并且在轨道表中有: id name desc Artistid

所以如果我 goto track.php?id=1 然后他们打印 id name desc artistid我想让这个显示艺术家表中的记录并识别 id

你能告诉我如何从记录集中制作多个过滤器吗?因为当值为 1 时我有字段“pubid”,这意味着发布,然后如果值为 2,则意味着取消发布

抱歉英语不好谢谢你

4

2 回答 2

0

看看SQL Join。为了只获取可能发布的记录,您必须添加另一个WHERE子句。喜欢:

SELECT name, desc FROM track WHERE id = $id AND pubid = 1;

于 2012-05-18T05:06:48.337 回答
0

track.php?id=1 或 track.php?id=1&pubid=1 track.php?id=1&pubid=2

<?php

if (isset($_GET['id'])) {
    $artistid = $_GET['id'];
    if (isset($_GET['pubid'])) {
        $pudid = $_GET['pubid']; 
        $sql = "select `id`, `name` from `track` where `artistid` = {$artistid} and `pubid` = {$pupid} order by `desc`";

    } else
        $sql = "select `id`, `name` from `track` where `artistid` = {$artistid} order by `desc`";

    $query = mysql_query($sql);
    while (($row = mysql_fetch_array($query)) !== false) {
       echo $row['name'];
    }
}
于 2012-05-18T05:10:05.940 回答