jefffogel1974 Posted October 20, 2009 Share Posted October 20, 2009 I have a MySQL db with all my servers and all their details like server name, IP, OS, RAM etc etc 26 in total. I have a PHP page which will list all server names with a link on the page and when you click the link its suppose to go to a page that is called serverdetails.php which it does, but how do I only list information from the one server of the link I clicked on? Below is the code I am using to go to the next page. echo "<A HREF=\"http://vm-webdev/serverdetails?svr={$row['Server_Name']}\">{$row['Server_Name']}</A><br>"; Quote Link to comment Share on other sites More sharing options...
Bricktop Posted October 20, 2009 Share Posted October 20, 2009 Hi jefffogel1974, You would need to perform a MySQL Query on serverdetails.php which will use the server name (assuming $row['Server_name'] is unique) and perform a WHERE statement. For example: <?php //This make_safe() function sanitises anything passed to it - ideal for $_GET and $_POST values function make_safe($unsafe) { require("connect/config.inc.php"); $safe = mysql_real_escape_string(strip_tags(trim($unsafe))); return $safe; } $sql = mysql_query("SELECT * FROM yourtable WHERE servername = '".make_safe($_GET['svr'])."' ORDER BY id"); If $row['Server_Name'] is not unique, you would need to do the above but using the auto-incrementing id each row has, as this is always unique. Obviously, your link code would need to be amended accordingly, i.e.: echo "<A HREF=\"http://vm-webdev/serverdetails.php?id={$row['id']}\">{$row['Server_Name']}</A><br>"; The MySQL query would then need to read something like: $sql = mysql_query("SELECT * FROM yourtable WHERE id = '".make_safe($_GET['id'])."' ORDER BY id"); Hope this helps. Quote Link to comment 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.