cyber15 Posted April 14, 2022 Share Posted April 14, 2022 I'm trying to make a news portal that directs you to different page when you click on 'Read' button. When I link the 'Read' button, it applies to all the 'Read' button. I want to know how to link it like this for example: Storm news Click 'Read' -> Link to this storm article Flood news Click 'Read' -> Link to this food article Sorry for my poor english. Quote Link to comment https://forums.phpfreaks.com/topic/314698-how-do-i-set-button-that-directs-to-different-page/ Share on other sites More sharing options...
Barand Posted April 14, 2022 Share Posted April 14, 2022 (edited) Easiest way is to use a link <a>..</a> which takes you to the required page, passing the id of the article in the query string. Style the link to look like a button. For example <head> <title>Example</title> <style type='text/css'> body { font-family: verdana, sans-serif; font-size: 11pt; } .link-button { display: inline-block; width: 50px; padding: 5px; margin-left: 16px; background-color: blue; color: white; border: 1px solid black; text-align: center; text-decoration: none; border-radius: 8px; } .link-button:hover { background-color: gray; } </style> </head> <body> <p> Storm news <br> <a href='read_article.php?id=1' class='link-button'>Read</a> </p> <p> Flood news <br> <a href='read_article.php?id=2' class='link-button'>Read</a> </p> </body> giving Edited April 14, 2022 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/314698-how-do-i-set-button-that-directs-to-different-page/#findComment-1595323 Share on other sites More sharing options...
ginerjm Posted April 14, 2022 Share Posted April 14, 2022 What I do this to use unique values on the submit tags and let my main script decide what to do. If you want it to go to a different script, when you see that button value you issue a header to that script. Quote Link to comment https://forums.phpfreaks.com/topic/314698-how-do-i-set-button-that-directs-to-different-page/#findComment-1595324 Share on other sites More sharing options...
morocco-iceberg Posted October 2, 2022 Share Posted October 2, 2022 You can also use JavaScript onClick if you wanted any loading animations or to process information before navigating away, but for basic navigation tags should suffice Quote Link to comment https://forums.phpfreaks.com/topic/314698-how-do-i-set-button-that-directs-to-different-page/#findComment-1601265 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.