php中返回值的链接

ybzsozfc  于 2021-06-21  发布在  Mysql
关注(0)|答案(2)|浏览(327)

我有一个脚本,正在查找存储在数据库中的跟踪号码。当前,它以文本形式返回跟踪号。如何使其成为将返回结果放入链接的超链接
我需要包括链接http://wwwapps.ups.com/webtracking/track?track=yes&tracknums={追踪号码}

<html>
<head>
<title>Search</title>
</head>

<body>
<div class="logo" align="center">
    <img src="./gplogo.png">
    </div>
    <form action="./index.php" method="get" align="center" ><br>
    <h1>Sample Order Tracking</h1>

    <label>Search By Company, Zip, or City:
        <input type="text" name="keywords">
    </label>
        <input type="submit" value="search" autocomplete="off">
    </form>

    <?php

   $db = new mysqli("localhost", "root", "", "samples");

   if(isset($_GET['keywords'])) {

        $keywords = $db->escape_string($_GET['keywords']);

        $query = $db->query("
            SELECT Company, Attention, Address1, ST_City, ST_State, ST_PostalCode, Pak_TrackingNumber
            FROM samples
            WHERE ST_PostalCode LIKE '%{$keywords}%'
            OR Company LIKE '%{$keywords}%'
            OR ST_City LIKE '%{$keywords}%'
        ");
   ?>

   <div class="resul-count" align="center">
    Found <?php echo $query->num_rows; ?> Results.
    </div><br>
<table border="1" align="center" cellpadding="15px">    
    <?php

        if($query->num_rows){
            while($r = $query->fetch_object()){
            ?>
            <div class="result">
                    <tr>
    <td><?php echo $r->Company;   ?></td>
    <td><?php echo $r->Attention; ?></td>
    <td><?php echo $r->Address1; ?></td>
    <td><?php echo $r->ST_City;   ?></td>
    <td><?php echo $r->ST_State; ?></td>
    <td><?php echo $r->ST_PostalCode; ?></td>
    <td><?php echo $r->Pak_TrackingNumber; ?></td>
</tr>
                </div>
            <?php
        }

}
}   
?>
</body>

</html>
qaxu7uf2

qaxu7uf21#

尝试将其嵌入应答器标签:

echo "<a href='http://www.apps.ups.com/WebTracking/track?track=yes&trackNums=$yourVariable'>redirect_link</a>";
bihw5rsg

bihw5rsg2#

您只需使用href标记将其 Package 如下:

<td><a href="http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=<?= $r->Pak_TrackingNumber; ?>"><?= $r->Pak_TrackingNumber;?></a></td>

相关问题