猿问

为值添加前缀以建立链接

我正在从数据库返回一个跟踪号,并希望将其设为可点击的链接。

<td><?php echo $row['tracking_number']; ?></td>

前缀是“ http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums= ”

http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=TRACKINGNUMBER


杨魅力
浏览 184回答 3
3回答

慕的地10843

在此要求的下方使用echo&nbsp;"http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=" &nbsp;&nbsp;&nbsp;&nbsp;.&nbsp;$row['tracking_number'];

繁星点点滴滴

$link='http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums='$link.=$row['tracking_number'];

慕无忌1623718

<td>&nbsp; &nbsp; <?php&nbsp; &nbsp; &nbsp; &nbsp; $link_href = 'http://wwwapps.ups.com/WebTracking/track?'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; . http_build_query(['track' => 'yes', 'trackNums' => $$row['tracking_number']]);&nbsp; &nbsp; &nbsp; &nbsp; echo '<a href="' . $link_href . '">' . $row['tracking_number'] . '</a>';&nbsp;&nbsp; &nbsp; ?></td>如果$row['tracking_number']是字符串,则不需要进一步更改,但如果是跟踪号数组,则$tracking_numbers = implode(',', $row['tracking_number']);可以插入并$tracking_numbers替换$row['tracking_number']);.
随时随地看视频慕课网APP
我要回答