Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head><title>Drop-down test</title></head>
- <body>
- <!--Makes it so the drop down items are queried from the database><-->
- <?php
- error_reporting(0);
- include ('db_login.php');
- $connection = mysql_connect($db_host,$db_username,$db_password);
- if (!$connection) die ('Error1!'.mysql_error());
- $db_select = mysql_select_db($db_database);
- if (!$db_select) die ('Error2!'.mysql_error());
- $query = "SELECT column_1 from first_table";
- $result = mysql_query($query);
- if (!$result) die ('Error3!'.mysql_error());
- echo ('
- <form action="'.$_SERVER['PHP_SELF'].'" method="GET">
- <select name="search">
- ');
- while ($result_row = mysql_fetch_row($result)) {
- echo ('
- <option>'.$result_row[0].'</option>
- ');
- }
- echo ('
- </select>
- <input type="submit" value="Go!">'.
- '</form>
- ');
- ?>
- <p>
- <?php
- function returnletters($value1) {
- if ($value1 != NULL) {
- $query2 = "SELECT column_2 from first_table WHERE column_1 = $value1";
- $results = mysql_query($query2);
- if (!$results) die ('Error4!'.mysql_error());
- while ($result_row = mysql_fetch_row($results)){
- echo ('
- The corresponding letters to this are: <strong>'.$result_row[0].'</strong><br>
- ');
- }
- }
- else die ('Error5!');
- }
- ?>
- <?php
- $value = $_GET['search'];
- returnletters($value);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement