简体   繁体   English

PHP-加载可变页面内容

[英]PHP - Load variable page content

Apologies again, as I'm new to PHP so not fully sure how this works, but thought I'd ask. 再次道歉,因为我是PHP新手,所以不完全确定这是如何工作的,但我想问一下。

I have a page called contract.php, which I'm hoping to use as a template so that when someone selects the contract they wish to view it goes to the contract.php and loads the content for that particular contract. 我有一个名为contract.php的页面,我希望将其用作模板,以便当某人选择合同时,他们希望查看的合同转到了contract.php并加载了该特定合同的内容。

Hopefully I shouldn't need to create a page for every single contract, I was hoping that I could use the contract ID, so that when the navigate to the page it would show something like contracts.php?contractid=555 and then loads the contracts details for contractid 555, so this does this for each new contract that's listed. 希望我不需要为每个合同创建一个页面,我希望可以使用合同ID,这样当导航到该页面时,它将显示诸如Contracts.php?contractid = 555之类的内容,然后加载合约ID 555的合约详细信息,因此对列出的每个新合约都执行此操作。

The issue I'm having is, I'm not sure how best to go about it, or how to use this ?contractid='xxx' etc. 我遇到的问题是,我不确定如何做到最好,或如何使用此?contractid ='xxx'等。

Any help would be appreciated. 任何帮助,将不胜感激。

Many thanks 非常感谢

You can fetch respective data from your database for each contract using the contract ID. 您可以使用合同ID从数据库中获取每个合同的相应数据。 Inside the contracts.php , check whether contractid variable is set and not empty, using isset($_GET['contractid']) && !empty($_GET['contractid']) . Contracts.php内部,使用isset($_GET['contractid']) && !empty($_GET['contractid'])检查是否设置了contractid变量且不为空。 If it is true, then fetch respective data from the DB and display it to the user, in the template that you must have created. 如果为true,则在您必须创建的模板中,从数据库中获取相应的数据并将其显示给用户。

Hope this helps. 希望这可以帮助。 If you need more help then paste your code here. 如果您需要更多帮助,请在此处粘贴代码。

$_GET manual . $ _GET manual

after reading the contract id from the get variable, you can search your DB for that contract and echo the specific data of this contract. 从get变量中读取合同ID后,您可以在数据库中搜索该合同并回显该合同的特定数据。

Also consider using $_POST so that you can't easily see any contract by changing the url by yourself 还可以考虑使用$ _POST,这样您就无法通过自己更改url来轻松查看任何合同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM