如何在超链接中显示 PHP 变量?

编程入门 行业动态 更新时间:2024-10-10 12:26:41
本文介绍了如何在超链接中显示 PHP 变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试回显一个变量,以便它显示在我的超链接中.这是我当前的代码:

I'm trying to echo a variable so it shows in my hyperlink. Here's my current code:

<?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); $customerserviceid = mysql_query("SELECT id FROM `tblhosting` WHERE `userid` = '{$_SESSION['uid']}'"); function limitOrders($vars) { if(mysql_num_rows(mysql_query("SELECT packageid FROM `tblhosting` WHERE `userid` = '{$_SESSION['uid']}'")) > 0) { if($packageid = '1' || $packageid = '2' || $packageid = '3' || $packageid = '4' || $packageid = '5' || $packageid = '6' || $packageid = '7' || $packageid = '8' || $packageid = '9' || $packageid = '10') { global $errormessage; $errormessage = "<li>It looks like you already have an account! Please <a href='mywebsite/upgrade.php?type=package&id=$customerserviceid'>click here</a> to upgrade or downgrade your account.</li>"; } } } add_hook("ShoppingCartValidateCheckout", 1, "limitOrders"); ?>

我尝试将 $customerserviceid 添加到第 14 行的 URL 中,但它只显示空白,所以我猜我没有正确添加某些内容.当我在 phpMyAdmin 中运行查询时,它确实显示了我想要的内容,因此查询本身应该是正确的...

I tried adding $customerserviceid into the URL on line 14 but it just shows blank so I'm guessing that I didn't add something correctly. When I run the query in phpMyAdmin it does show what I'm wanting so the query itself should be correct...

推荐答案

需要从查询结果中取出结果,然后使用global访问全局变量.

You need to fetch the results from the query results, and then use global to access the global variable.

<?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); $result = mysql_query("SELECT id FROM `tblhosting` WHERE `userid` = '{$_SESSION['uid']}'"); $row = mysql_fetch_assoc($result); $customerserviceid = $row['id']; function limitOrders($vars) { global $customerserviceid; if(mysql_num_rows(mysql_query("SELECT packageid FROM `tblhosting` WHERE `userid` = '{$_SESSION['uid']}'")) > 0) { if($packageid = '1' || $packageid = '2' || $packageid = '3' || $packageid = '4' || $packageid = '5' || $packageid = '6' || $packageid = '7' || $packageid = '8' || $packageid = '9' || $packageid = '10') { global $errormessage; $errormessage = "<li>It looks like you already have an account! Please <a href='mywebsite/upgrade.php?type=package&id=$customerserviceid'>click here</a> to upgrade or downgrade your account.</li>"; } } } add_hook("ShoppingCartValidateCheckout", 1, "limitOrders"); ?>

更多推荐

如何在超链接中显示 PHP 变量?

本文发布于:2023-11-28 08:39:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641698.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   超链接   如何在   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!