0

For some reason, my data isn't appearing on the webpage when I click the button for it to show. It was working a few days ago, but now it's not. I don't remember making any significant changes. Anyone know what's going on?

Code:

<html>
<head>
<title>Database</title>
</head>
<body>
<div id="casing">
<form action="filmsdatabase.php" method="GET">
<div id="Films"><input type="submit" name="button" value="show films"  /></div>
</form>
</div>

<?php 
    $db = mysql_connect("cs4111.cshve4dssdhm.us-west-2.rds.amazonaws.com","username","password"); 
    if (!$db) {
        die("Database connection failed miserably: " . mysql_error());
        echo "Failed to Connect";
    }
    $db_select = mysql_select_db("cs4111",$db);
    if (!$db_select) {
        die("Database selection also failed miserably: " . mysql_error());
        echo "Failed to Connect";
    }
    if(isset ($GET["button"]) && $GET["button"] == "show films"){
         $result = mysql_query("SELECT * FROM films", $db);
         if (!$result) {
            die("Database query failed: " . mysql_error());
         }
         while ($row = mysql_fetch_array($result)){
             echo "<h2>";
             echo $row[1]."";
             echo "</h2>";
             echo "<p>";
             echo $row[2]."";
             echo "</p>";   
             echo "Duration: ", $row[3]."", " minutes";
             echo "</p>";
             echo "Genre: ", $row[4]."";
             echo "</p>";
         }
     }
?>
 </body>
</html>
<?php
mysql_close($db);
?>
ojbomb227
  • 3
  • 1
  • 2

1 Answers1

2

Just a quick glance at the code here, I think you are actually looking to use $_GET instead of $GET.

if(isset ($_GET["button"]) && $_GET["button"] == "show films"){

This uses PHPs $_GET global variable.

aaronott
  • 396
  • 1
  • 6