gpt4 book ai didi

php - 在 php 中链接返回值

转载 作者:行者123 更新时间:2023-11-30 21:42:41 25 4
gpt4 key购买 nike

我有一个脚本可以查找存储在数据库中的跟踪号码。目前它以文本形式返回跟踪号。我怎样才能使它成为一个超链接,将返回的结果放入链接中

我需要包含链接 http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums= {tracking_number}

    <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>

最佳答案

你只需要像这样用 href 标签包裹它:

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

关于php - 在 php 中链接返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50861773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com