Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head><title>Building A Form</title></head>
- <body>
- <p>
- <?php
- error_reporting(0);
- $search = $_GET["search"];
- $self=$_SERVER["PHP_SELF"];
- //default
- if ($search != NULL){
- include ('db_login.php');
- $connection = mysql_connect($db_host, $db_username, $db_password);
- if (!$connection) {
- die ("Could not connect to the database: <br />".mysql_error());
- }
- else{
- echo ("Connection established!<p>");
- }
- echo ('<p>Your search was: '.$search.'.<p>
- ');
- $db_select=mysql_select_db($db_database);
- if (!$db_select){
- die ("Could not select the database: <br />".mysql_error());
- }
- $select=' SELECT ';
- $column=' * ';
- $from =' from ';
- $first_table =' first_table ';
- //$query=$select.$column.$from.$first_table;
- $query="SELECT * from first_table WHERE column_1 = $search ";//this work?
- $result=mysql_query($query);
- if (!$result){
- die ("Could not query the database: <br />".mysql_error());
- }
- echo ('<table border="1">');
- echo ('<tr><th>Numbers</th><th>Letters</th></tr>');
- while ($result_row = mysql_fetch_row($result)) {
- echo ('<tr><td>');
- echo ($result_row[0]. '</td><td>');
- echo ($result_row[1]. '</td></tr>');
- }
- mysql_close($connection);
- echo ('<p><a href ="simple.php">Try again?</a>');
- }
- else {
- echo('
- <form action="'.$_SERVER["PHP_SELF"].'" method="GET">
- <label>Search: <input type=text name="search" /></label>
- <input type="submit" value="Go!" />
- </form>
- <p>Enter "123", "234", or "345"
- ');
- }
- ?>
- <p><a href ="index.html">Back</a>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement