There must be an easy answer to this; how do I use the ? extension to a filename, e.g. somefile.php?id=8 in a website to get a row back from a database? I have set up a simple database and can access it with direct commands in a php file, but the next step has defeated me!

    If you call your script with something like somefile.php?id=8 in the URL, then in PHP those key/value pairs will be available in the $_GET "super-global" array. In this example, $_GET['id'] would have a value of "8". You could therefore use that array element in your DB query, being sure to sanitize it as applicable for the database extension you're using to avoid SQL injection attacks (or accidents).

      Write a Reply...