php& mysql查询没有用带标签的html回显?

时间:2013-12-31 22:03:29

标签: php

<?php
require 'db.php';
?>

<?php
if (isset($_POST['search']))
{
$limit = $_POST['limit'];
$country = $_POST['country'];
$state = $_POST['state'];
$city = $_POST['city'];
$data = mysqli_query($link,"SELECT * FROM proxies WHERE country = '{$country}' AND state = '{$state}' AND city = '{$city}' LIMIT {$limit}");
while( $assoc = mysqli_fetch_assoc($data)){
$proxy = $assoc['proxy'];
echo '<<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sock5Proxies</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link href="./style.css" rel="stylesheet" type="text/css" />
<link href="./buttons.css" rel="stylesheet" type="text/css" />
</head>
<center>
<h1>Sock5Proxies</h1>
</center>
<body>
<div id="wrapper">
    <div id="header">
        <ul id="nav">
           <li class="active"><a href="index.html"><span></span>Home</a></li> 
           <li><a href="leads.html"><span></span>Leads</a></li> 
           <li><a href="payout.php"><span></span>Pay out</a></li> 
           <li><a href="contact.html"><span></span>Contact</a></li> 
           <li><a href="logout.php"><span></span>Logout</a></li>
        </ul>
    </div>
    <div id="content">
        <div id="center">
            <table cellpadding="0" cellspacing="0" style="width:690px">
                <thead>
                    <tr>
                        <th width="75" class="first">Proxy</th>
                        <th width="50" class="last">Status</th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="rowB">
                        <td class="first"> <?php echo $proxy ?> </td>
                        <td class="last">Check</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    </center>
    </center>
    <div id="footer"></div>
    <span id="about">Version 1.0</span>
</div>

</body>
</html>';
}
}
?>
<html>
<form action="" method="POST">
<input type="text" name="limit" placeholder="10"/><br>
<input type="text" name="country" placeholder="Country"/><br>
<input type="text" name="state" placeholder="State"/><br>
<input type="text" name="city" placeholder="City"/><br>
<input type="submit" name="search" value="Search" /><br>
</form>
</html>

我现在第47行没有收到任何错误,这应该是打印出我的查询,它没有html&amp;样式,在你问之前主题是否有效,如style.css。

4 个答案:

答案 0 :(得分:2)

<td class="first"> <?php echo $proxy ?> </td> 里面你是echo的文字字符串。结束字符串,或正确连接:

<td class="first">' . $proxy . '</td>

答案 1 :(得分:1)

<?php echo $proxy ?>更改为' . $proxy . '

当您使用<?php的PHP模式输出HTML时,可以使用?>。使用echo时,必须使用连接,或用双引号包装字符串并使用插值。

答案 2 :(得分:1)

我可以发现一些不同的问题。但是,为了节省时间,请尝试使用以下代码:

<?php
require 'db.php';
?>

<?php
if (isset($_POST['search'])) {
    $limit = $_POST['limit'];
    $country = $_POST['country'];
    $state = $_POST['state'];
    $city = $_POST['city'];
    $data = mysqli_query(
        $link,
        "SELECT * FROM proxies WHERE country = '{$country}' AND state = '{$state}' AND city = '{$city}' LIMIT {$limit}"
    );
    while ($assoc = mysqli_fetch_assoc($data)) {
        $proxy = $assoc['proxy'];
        ?>
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                    <title>Sock5Proxies</title>
                    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
                    <link href="./style.css" rel="stylesheet" type="text/css" />
                    <link href="./buttons.css" rel="stylesheet" type="text/css" />
                </head>
                <body>
                    <center>
                        <h1>Sock5Proxies</h1>
                    </center>
                    <div id="wrapper">
                        <div id="header">
                            <ul id="nav">
                                <li class="active"><a href="index.html"><span></span>Home</a></li>
                                <li><a href="leads.html"><span></span>Leads</a></li>
                                <li><a href="payout.php"><span></span>Pay out</a></li>
                                <li><a href="contact.html"><span></span>Contact</a></li>
                                <li><a href="logout.php"><span></span>Logout</a></li>
                            </ul>
                        </div>
                        <div id="content">
                            <div id="center">
                                <table cellpadding="0" cellspacing="0" style="width:690px">
                                    <thead>
                                    <tr>
                                        <th width="75" class="first">Proxy</th>
                                        <th width="50" class="last">Status</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr class="rowB">
                                        <td class="first"> <?php echo $proxy ?> </td>
                                        <td class="last">Check</td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div id="footer"></div>
                        <span id="about">Version 1.0</span>
                    </div>
                </body>
            </html>
        <?php
    }
}
?>
<html>
<form action="" method="POST">
    <input type="text" name="limit" placeholder="10" /><br>
    <input type="text" name="country" placeholder="Country" /><br>
    <input type="text" name="state" placeholder="State" /><br>
    <input type="text" name="city" placeholder="City" /><br>
    <input type="submit" name="search" value="Search" /><br>
</form>
</html>

答案 3 :(得分:0)

您需要将变量附加到回显的字符串。例如:

echo 'This is a string '.$PHPvariable.' and this is more string';