Home  >  Q&A  >  body text

How does tp5 implement a template request function based on ID and return the name of the requested ID?

How to implement template request function in tp5 and return the name of the requested ID

[Product table]: product
----------------- ------
id | name
1 | PC website
2 | Mobile website
3 | Mini program
-------------- ---------

[Customer table]: client
-------------------------- ---------
id | name | product_id
1 | Customer A | ["1","2","3"]
--------- --------------------------


When rendering data in the "Customer Template" list, how to use "prodect_id" "The ID inside gets the name value corresponding to the ID in the "product" table. If it is ajax, there is a delay in returning the data. I want to get it by calling the function method directly through the template; if there are other better methods, I hope you can tell me

“橙”-景安服务器**“橙”-景安服务器**2346 days ago1247

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2018-06-05 14:28:07

    It is recommended to create a custom function directly in common.php to solve the problem

    reply
    0
  • “橙”-景安服务器**

    Can this be queried using a SQL statement linked list?

    “橙”-景安服务器** · 2018-06-05 14:38:08
  • Cancelreply