为sql添加额外的php参数

时间:2015-08-16 13:52:18

标签: php

所以即时制作一个有8个链接的迷你网页,男性4个,女性4个,每个有2条裤子和2条裤子。现在我已经制作了5个php页面并编写了脚本,但男性衬衫和裤子不起作用。有谁知道我能做些什么让它们起作用?我发布了我的teedetails.php页面代码和listoftees.php页面代码,因为两个裤子页面基本相同。

teedetails:

<?php
    $selection = $_GET["id"];
    mysql_connect("localhost", "root", "");
    mysql_select_db("clothesshop");
    $sql = "select * from tshirts where tid=$selection;";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
?>

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="boilerplate.css">
        <link rel="stylesheet" href="teedetails.css">
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0">
    </head>
    <body>
        <div id="primaryContainer" class="primaryContainer clearfix">
            <div id="box" class="clearfix">
                <img id="image" src="img/300-lacoste_logo.png" class="image" />
            </div>
            <div id="box2" class="clearfix">
                <p id="text5">
                    <a id="textspan" href="listoftees.php?g=Women&c=everyday tees">Everyday Tees </a><br />
                </p>
                <p id="text6">
                    <a id="textspan1" href="listoftees.php?g=Women&c=fashion tees">Fashion Tees </a><br />
                </p>
                <p id="text7">
                    <a id="textspan2" href="listofpants.php?g=Women&c=corduroy pants">Corduroy Pants</a><br />
                </p>
                <p id="text8">
                    <a id="textspan3" href="listofpants.php?g=Women&c=artist pants">Artist Pants </a><br />
                </p>
            </div>
            <div id="box3" class="clearfix">
                <p id="text9">
                    Men
                </p>
            </div>

            <div id="box4" class="clearfix">
                <p id="text16">
                    <a id="textspan4" href="listoftees.php?g=Men&c=long sleeve tees">Long Sleeve Tees </a><br />
                </p>
                <p id="text17">
                    <a id="textspan5" href="listoftees.php?g=Men&c=fashion tees">Fashion Tees</a><br />
                </p>
                <p id="text18">
                    <a id="textspan6" href="listofpants.php?g=Men&c=original straight pants">Original Straight Pants</a><br />
                </p>
                <p id="text19">
                    <a id="textspan7" href="listofpants.php?g=Men&c=cargo pants">Cargo Pants</a><br />
                </p>
            </div>
            <article>
                <h1><?php echo $row["tname"]; ?> // <?php echo number_format($row["tprice"], 2); ?>;</h1>
                <img src="img/<?php echo $row["tbig"]; ?>" alt="">
            <p id="text14"><?php echo $row["tdesc"]; ?></p>
            <p>
                <span class="infohdr">Category:</span><?php echo $row["tcat"]; ?>
                <span class="infohdr">Colors:</span><?php echo $row["tcolors"]; ?>
                <span class="infohdr">Sizes:</span><?php echo $row["tsizes"]; ?>
            </p>
        </article>
    </div>
</body>

listoftees.php: &#34;

<?php
    $gen = $_GET["g"];
    $cat = $_GET["c"];
    mysql_connect("localhost", "root", "");
    mysql_select_db("clothesshop");
    $sql = "select * from tshirts where tgender='$gen' and tcat='$cat';";
    $result = mysql_query($sql);
?>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="boilerplate.css">
        <link rel="stylesheet" href="listoftees.css">
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0">
    </head>
<body>
    <div id="primaryContainer" class="primaryContainer clearfix">
        <div id="box" class="clearfix">
            <img id="image" src="img/300-lacoste_logo.png" class="image" />
        </div>
        <div id="box2" class="clearfix">
            <p id="text5">
                <a id="textspan" href="listoftees.php?g=Women&c=everyday t shirt">Everyday Tees </a><br />
            </p>
            <p id="text6">
                <a id="textspan1" href="listoftees.php?g=Women&c=fashion T shirt">Fashion Tees </a><br />
            </p>
            <p id="text7">
                <a id="textspan2" href="listofpants.php?g=Women&c=corduroy pants">Corduroy Pants</a><br />
            </p>
            <p id="text8">
                <a id="textspan3" href="listofpants.php?g=Women&c=artist pants">Artist Pants </a><br />
            </p>
        </div>
        <div id="box3" class="clearfix">
            <p id="text9">
                Men
            </p>
        </div>
        <div id="box4" class="clearfix">
            <p id="text16">
                <a id="textspan4" href="listoftees.php?g=Men&c=long sleeve">Long Sleeve Tees </a><br />
            </p>
            <p id="text17">
                <a id="textspan5" href="listoftees.php?g=Men&c=fashion t shirt">Fashion Tees</a><br />
            </p>
            <p id="text18">
                <a id="textspan6" href="listofpants.php?g=Men&c=original straight pants">Original Straight Pants</a><br />
            </p>
            <p id="text19">
                <a id="textspan7" href="listofpants.php?g=Men&c=cargo pants">Cargo Pants</a><br />
            </p>
        </div>
        <?php while ($row = mysql_fetch_array($result)) {?>
            <article>
                <a href="teedetails.php?id=<?php echo $row ["tid"]; ?>">
                <img id="image3" src="img/<?php echo $row ["tsmall"]; ?>" class="image" />
                <h2 class="itemname"><a href="teedetails.php?id=<php echo $row ["tid"]; ?>"><?php echo $row ["tname"]; ?>"></h2></a>
                <h3 class="price">$<?php echo number_format($row["tprice"], 2); ?>"></h3>
                <p class="desc"><?php echo $row ["tdesc"]; ?>"></p>
            </article>
        <?php } ?>
    </div>
</body>
</html>

是的,有一个女性的标签。但由于某种原因它没有在这个网站上工作,div id是box1和text 1

0 个答案:

没有答案