$con = mysql_connect("localhost","retrodex","Vitaladam1"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("gamesforsale", $con); // We now need to setup our SQL query to grab all comments from this page. // The example SQL query we copied from phpMyAdmin is: // SELECT * FROM `comments` WHERE `articleid` =1 LIMIT 0 , 30 // If we run this query, it will ALWAYS grab only the comments from our // article with an id of 1. We therefore need to update the SQL query // so that on article 2 is searches for the "2", on page is searches for // "3", and so on. // If you notice in the URL, the id of the article is set after id= // For example, in the following URL: // https://phpandmysql.inmotiontesting.com/page2.php?id=2 // ... the article id is 2. We can grab and store this number in a variable // by using the following code: $article_id = $_GET['Serial']; // We also want to add a bit of security here. We assume that the $article_id // is a number, but if someone changes the URL, as in this manner: // https://phpandmysql.inmotiontesting.com/page2.php?id=malicious_code_goes_here // ... then they will have the potential to run any code they want in your // database. The following code will check to ensure that $article_id is a number. // If it is not a number (IE someone is trying to hack your website), it will tell // the script to stop executing the page if( ! is_numeric($article_id) ) die('invalid article id'); // Now that we have our article id, we need to update our SQL query. This // is what it looks like after we update the article number and assign the // query to a variable named $query $query = "SELECT * FROM `gamesforsale` WHERE `Type` LIKE 'Game'"; // Now that we have our Query, we will run the query against the database // and actually grab all of our comments $gamesforsale = mysql_query($query); // Before we start writing all of the comments to the screen, let's first // print a message to the screen telling our users we're going to start // printing comments to the page. echo "