Hey everyone!

With the holiday season upon us, we want to share our upcoming working hours:

After that, we’ll return to our regular schedule and assist you as quickly as possible.

In the meantime, you can explore our documentation for Amelia and wpDataTables. You'll find tons of helpful resources, including articles and handy video tutorials on YouTube (Amelia's YouTube Channel and wpDataTables' YouTube Channel), which might just have the answers you need while we’re away.

Thanks a bunch for your understanding and support!

Warm regards and happy holidays!

TMS

Okay
  Public Ticket #2931220
Create a link using the user_id obtained by SQL
Closed

Comments

  • Kohei started the conversation

    I created a table using SQL.

    Code:

    SELECT id AS UserID FROM wp_users

    Execution result:

    UserID
    1
    2
    3
    4
    ...

    I want to use this to create a link to the user page.

    ProfilePage
    mydomain/wp-admin/user-edit.php?user_id=1
    mydomain/wp-admin/user-edit.php?user_id=2
    mydomain/wp-admin/user-edit.php?user_id=3
    mydomain/wp-admin/user-edit.php?user_id=4
    ...


    Is there a way to achieve this?



  • [deleted] replied

    Hi Kohei

    Thank you for reaching out to us.

    If I understand correctly you want an entry from the table as a hyperlink that would take the visitor to the specific post or page? That link would be dynamically generated by the content of the cell, right? 

    If that's true, you could use the CONCAT function, like this: 

    SELECT column1,column2,       
    CONCAT('<a href="www.yourwebsite.com/page1/',yourTable.column3,'">',yourtable.column3,'</a>') 
    AS HyperlinkFROM yourTable 

    This will create a hyperlink to www.yourwebsite.com/page1/value1 if there's "value1" entered as cell data in column3. On another row, it could be www.yourwebsite.com/page1/value2 if there's "value2" in the cell, and so on. So, this would be a hyperlink which could be shown in the modal, and it would take the user to the respective page.

    I hope this helps, do let us know if you need any further assistance.

  • Kohei replied

    Hi Blaženka,

    Thank you! It certainly did what I wanted it to do with this code.

    One more question, how can I open the hyperlink created in this way in Modal? You said "this would be a hyperlink which could be shown in the modal", but these hyperlink are normal link.

    I would like to open the link in modal if possible.

  • [deleted] replied

    Hi Kohei

    Please have a look at our Master Detail addon which you can use to display information in this way

    https://wpdatatables.com/documentation/addons/master-detail-tables/

    Do let us know if you need any further assistance. 

  • Kohei replied

    Hi Blaženka,

    I understand that the MD add-on popup is for a horizontal table with many columns (e.g. 50 columns), and if the first 5 columns are displayed, clicking on a row will show the information contained in the remaining 45 columns.

    Is my understanding of the above wrong?

    If I use the MD add-on, am I correct in assuming that the table containing the URL (link) will open the link as a popup (like an iframe) when I click on the link?


  • [deleted] replied

    Hi Kohei

    You can choose what information you want to display in the MD modal, so it doesn't have to be just additional information from other columns, you can choose to display only this link on a row click but if will still be displayed as a link you won't be able to display the content of the link in the modal I'm afraid. 

  • Kohei replied

    Hi Blaženka,

    Thank you! I'll look MD option. 

    Please close this ticket.

  • [deleted] replied

    You are most welcomesmile.png

    If there is anything else we can assist you with please don't hesitate to open a new ticket.

    Have a wonderful day!