我们可以在href而不是链接中传递变量吗? [英] Can we pass variable in href instead of link?

查看:188
本文介绍了我们可以在href而不是链接中传递变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将PDF的URL存储在MySQL数据库中。根据搜索条件,将从数据库中获取pdf的url,这意味着每次url都不同。所以url应该作为参数传递给的'href'。同时我不想在网页本身上显示url。一些文本或报告名称将在那里,当用户点击它时,它将转到那个pdf的URL。

有人可以告诉我如何将变量传递给href而不是传递url?



这里$ report_url在其他地方定义php文件,它存储从数据库中获取的url。并且$ report_result存储报告的名称。因此,点击此名称后,应该转到存储在$ report_url中的网址。







我们怎么做?



我尝试过:



$ result = mysqli_query($ db,$ sql);

$ count = mysqli_num_rows($ result);



if($ count == 0)

{

array_push($ errors,找不到给定条件的报告);

}

其他

{

while($ row = mysqli_fetch_array($ result))

{

$ rname = $ row ['report_pdf_url'];

$ pdf = $ row ['pdf_name'];



$ report_result。=''

Hi, I have stored the URL of pdf in MySQL database. Based on the search criteria the url of pdf will be fetched from the database which means everytime the url will be different. So the url should be passed as parameter to 'href' of .Also I don't want t show the url on the webpage itself. Some text or report name will be there and when user will click on that, it will go to that that url of pdf.
Can someone please tell me how I can pass the variable to href instead of passing the url?

Here $report_url is defined in other php file and it stores the url fetched from database. And "$report_result" stores the name of the report. So after clicking on this name it should go to that url stored in "$report_url".



How can we do this?

What I have tried:

$result=mysqli_query($db,$sql);
$count=mysqli_num_rows($result);

if($count==0)
{
array_push($errors,"No report found for given criteria");
}
else
{
while($row = mysqli_fetch_array($result))
{
$rname=$row['report_pdf_url'];
$pdf=$row['pdf_name'];

$report_result .='

'。$ pdf。'

';

$ report_url = $ rname;

}

---- -------------------------



< a href = $ report_url>< ;?php print($ report_result); ?>

推荐答案

report_url在其他php文件中定义,它存储从数据库中获取的url。并且
report_url is defined in other php file and it stores the url fetched from database. And "


report_result存储报告的名称。因此,点击此名称后,应该转到存储在
report_result" stores the name of the report. So after clicking on this name it should go to that url stored in "


report_url中的网址。







我们怎么做?



我尝试过:


report_url".



How can we do this?

What I have tried:


这篇关于我们可以在href而不是链接中传递变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆