从显示的数据库中检索id并传递到其他页面 [英] Retrieving id from database displayed and passing onto other page

查看:100
本文介绍了从显示的数据库中检索id并传递到其他页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在特定页面上显示数据库的内容(配方名称)。
我希望每个配方都可以打开到另一个页面。我知道我必须获得该特定配方的配方ID,将该ID传递到另一个页面并将配方内容打印到该页面上。我想知道如何检索特定食谱的独特配方ID ON BEING CLICKED (主要是)。

解决方案

如果您在特定页面上显示数据库的内容,那么您肯定使用了像 ASP 这样的服务器端脚本,或者 PHP 或者一些 JavaScript + AJAX 。我对此很不清楚。但是对于你的问题,我可以告诉你一件事,假如你使用PHP,那么你可能会显示链接为;

  echo'< a href =yourpage.php?recipeid ='。$ recepeid。'>'。$ recipiename。'< / a>'; 

其中 $ recipeid ID和 $ recipiename 是你的食谱的名称。在您的PHP文件( yourpage.php )中,您可以捕获这些数据,如 $ _ GET [recipeid]



您可以尝试Google搜索教程。

使用;

  $ strLink ='< a href =recipedisp.php?id ='。$ row ['id']。'>'。$ strName。' < / A>'; 
echo< li>。$ strLink。< / li>;

不要使用空格。


I'm displaying the contents of a database on a particular page(recipe names). I'd like each recipe to be a link which opens to another page. I understand I would have to obtain the recipe id for that particular recipe, pass the id to another page and print the recipe contents onto that page. I would like to know how to retrieve the unique recipe id of a particular recipe ON BEING CLICKED upon mainly.

解决方案

If you are displaying the contents of a database on a particular page, then definitely you are using a server side scripting like like ASP or PHP or some JavaScript + AJAX. I am quite unclear about that. But for your question, I can tell you one thing that, if, suppose you are using PHP, then you may display the link as;

echo '<a href="yourpage.php?recipeid='.$recepeid.'">'.$recipiename.'</a>';

where $recipeid is the variable carrying recipe id and $recipiename is the name of your recipe. In your PHP file (yourpage.php), you may catch this data like $_GET["recipeid"]

You may try a Google search for tutorials.

Use;

$strLink = '<a href="recipedisp.php?id='.$row['id'].'">'.$strName.'</a>';
echo "<li>".$strLink."</li>";

Don't use spaces.

这篇关于从显示的数据库中检索id并传递到其他页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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