lebedev9114 Posted October 9, 2009 Share Posted October 9, 2009 Hey, I am knew to php , any help would be appreciated. So in the database i want to create for example their is a name of a player Mark Macguire and I want to have another database field called MORE INFO , for every single following players name after Mark. the MORE INFO will direct a person to a new page . Here is what i got so far: <th><a href="/getlink.php?id=<?php echo $row['id']; ?>">More Info</a></th> I don't know however how to write the getlink.php which makes this code , work can anyone help out please! Link to comment https://forums.phpfreaks.com/topic/177074-creating-a-link-inside-a-loop-using-id/ Share on other sites More sharing options...
Bricktop Posted October 9, 2009 Share Posted October 9, 2009 Hi lebedev9114, A good start would be to use the $_GET function and use the variable retrieved to perform a query on your database. For example: <?php //This function makes $_GET or $_POST data safe function make_safe($unsafe) { require("your database connect script here.php"); $safe = mysql_real_escape_string(strip_tags(trim($unsafe))); return $safe; } //Perform the MySQL Query on the database based on the id $sql = mysql_query("SELECT * FROM database WHERE id = '".make_safe($_GET['id'])."' ORDER BY id"); I hope this helps. Link to comment https://forums.phpfreaks.com/topic/177074-creating-a-link-inside-a-loop-using-id/#findComment-933638 Share on other sites More sharing options...
heldenbrau Posted October 9, 2009 Share Posted October 9, 2009 Not sure if I understand, but I would change it from <a href="/getlink.php?id=<?php echo $row['id']; ?>">More Info</a> to <a href="/getlink.php?id=$row['id']">More Info</a> then the retrieving code $name = $_GET[id]; echo" Name: $name"; etc. If $name is going to be used in a database query then you need to make it safe. Link to comment https://forums.phpfreaks.com/topic/177074-creating-a-link-inside-a-loop-using-id/#findComment-933642 Share on other sites More sharing options...
lebedev9114 Posted October 9, 2009 Author Share Posted October 9, 2009 Thank you for the great posts, I got it to work ! Link to comment https://forums.phpfreaks.com/topic/177074-creating-a-link-inside-a-loop-using-id/#findComment-933650 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.