melting_dog Posted September 28, 2009 Share Posted September 28, 2009 HI all, Sorry this question might sound very 'newbie'. I have an HTML hyperlink and when clicked i want to run a query that will display the results on the page the hyperlink links to. Can anyone give me the basic structure of how this might be done? Cheers Link to comment https://forums.phpfreaks.com/topic/175771-help-with-hyperlink-triggering-an-sql-query/ Share on other sites More sharing options...
trq Posted September 28, 2009 Share Posted September 28, 2009 This is a php question rather than that of mysql, but anyway.... Given... <a href="foo.php?id=12">click</a> foo.php might look like.... <?php if (isset($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); $sql = "SELECT a,b FROM tbl WHERE id = $id LIMIT 1"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); echo $row['a'] . " " . $row['b']; } } } ?> Link to comment https://forums.phpfreaks.com/topic/175771-help-with-hyperlink-triggering-an-sql-query/#findComment-926256 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.