如何使用PHP + HTML在超链接中传递数据库值 [英] How to pass a database value in a hyperlink using PHP + HTML

查看:88
本文介绍了如何使用PHP + HTML在超链接中传递数据库值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在名为Artists的数据库中有一个表. 它包含两个频段. 我想做的是能够使用超级链接单击乐队名称,将该乐队名称发送到另一个要处理的php页面

I have a table in a database called Artists. It contains two bands. What I would like to do is to be able to click on the bands name using a hyper link, send that bands name to another php page to be processed

我拥有的超链接语法抛出错误:

The hyper link syntax i have is throwing up errors:

$query = "SELECT * FROM artists";

$result = mysql_query($query);

while($row = mysql_fetch_array($result))
{                                  
   echo     
    "<a target='Main_Frame' href=Side_Menu_ContentPrint.php?Aname=<?php echo 
    $_POST['ArtistName'] ?>" . $row['ArtistName'] . "</a>";         
}

因此,我希望以上超链接将乐队名称传递到Side_Menu_ContentPrint.php文件,以便可以在屏幕上回显它(并用于更多数据库查询).该文件连接到数据库并包含:

So I would like the above hyperlink to pass the bands name to Side_Menu_ContentPrint.php file so I can echo it to the screen (and use for more DB querying also). This file connects to the DB and contains:

$artist_Name = $_GET['Aname'];

echo "$artist_Name";

同样要显示的是,以下超级链接正在工作:

Just to show also, the following hyper link is working:

while($row = mysql_fetch_array($result))
{    
   echo     
   "<a target='Main_Frame' href=Side_Menu_ContentPrint.php>" . $row['ArtistName'] . "  
   </a>";                                                           
}

,然后单击它会回显一个测试词以证明它正在运行. 任何帮助都会很棒?

and when click on it echos a test word to prove that it is working. Any help would be great?

关于TW

推荐答案

您不能将PHP代码放入echo中并希望它能够再次运行.

you can't put PHP code into echo and hope that it will run again.

尝试一下

echo     
"<a target='Main_Frame' href='Side_Menu_ContentPrint.php?Aname=" . $row['ArtistName'] ."'>". $row['ArtistName'] . "</a>";     

这篇关于如何使用PHP + HTML在超链接中传递数据库值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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