Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>0802_Pass_Data_to_Select</title>
- </head>
- <body style="font-family: Arial, Helvetica, sans-serif; color: Blue; background-color:">
- <link rel="stylesheet" type="text/css" href="basic1.css">
- <form id="myform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
- <h2> Pass Data to a select statement</h2>
- <p> Enter SSN Code to see by state:
- <input type='text' name='ssncode' size='2' />
- </p>
- <?php
- //*************************************************
- //*
- //* Get SSN Code
- //*
- //**************************************************
- if (isset($_POST['ssncode']))
- {
- $ssncode = $_POST['ssncode'];
- if (empty($ssncode))
- {
- $ssncode = 'ALL';
- }
- } else {
- $ssncode = 'ALL';
- }
- //******************************************
- //* Connect to MYSQL and Database
- //*
- //******************************************
- $db = mysqli_connect('localhost','root','', 'working');
- if (!$db)
- {
- echo "<h1>Unable to Connect to MySQL</h1>";
- }
- //********************************************
- //*
- //* SELECT from table and dislay Results
- //*
- //*********************************************
- $sql_statement = "SELECT lighting ";
- $sql_statement .= "FROM lights ";
- if ($ssncode != 'ALL')
- {
- $sql_statement .= "WHERE lighting = '".$ssncode."' ";
- }
- $sql_statement .= "ORDER BY lighting ";
- $result = mysqli_query($db, $sql_statement); // Run SELECT
- $outputDisplay = "";
- $myrowcount = 0;
- if (!$result) {
- $outputDisplay .= "<p style='color: red;'>MYSQL No: ".mysqli_errno($db)."<br>";
- $outputDisplay .= "MYSQL Error: ".mysqli_error($db)."<br>";
- $outputDisplay .= "<br>SQL: ".$sql_statement."<br>";
- } else {
- if ($ssncode == 'ALL')
- {
- $outputDisplay = "<h3>SSN Codes for each person</h3>";
- } else{
- $outputDisplay = "<h3>SSN Codes for each person lives </h3>";
- }
- $outputDisplay .= '<table border=1 style="color: black;">';
- $outputDisplay .= '<tr><th>lighting<input type="checkbox" name="Aputure" value="Aputure">';
- $numresults = mysqli_num_rows($result);
- for ($i = 0; $i < $numresults; $i++)
- {
- if (!($i % 2) == 0)
- {
- $outputDisplay .= "<tr style=\"background-color: #F5DEB3;\">";
- } else {
- $outputDisplay .= "<tr style=\"background-color: white; cellpadding: 10;\">";
- }
- $myrowcount++;
- $row = mysqli_fetch_array($result);
- $lighting = $row['lighting'];
- $outputDisplay .= "<td>".$lighting."</td>";
- $outputDisplay .= "</tr>";
- }
- $outputDisplay .= "</table>";
- }
- if (isset ($_POST['Aputure']))
- {
- $Aputure = $_POST['Aputure'];
- } else {
- $Aputure = "";
- }
- if (isset ($_POST['Bescore']))
- {
- $Bescore = $_POST['Bescore'];
- } else {
- $Bescore = "";
- }
- if (isset ($_POST['Dedo']))
- {
- $Dedo = $_POST['Dedo'];
- } else {
- $Dedo = "";
- }
- if (isset ($_POST['Halogen']))
- {
- $Halogen = $_POST['Halogen'];
- } else {
- $Halogen = "";
- }
- if (isset ($_POST['Keno']))
- {
- $Keno = $_POST['Keno'];
- } else {
- $Keno = "";
- }
- if (isset ($_POST['LightingKit1']))
- {
- $LightingKit1 = $_POST['LightingKit1'];
- } else {
- $LightingKit1 = "";
- }
- if (isset ($_POST['LightingKit1']))
- {
- $LightingKit1 = $_POST['LightingKit1'];
- } else {
- $LightingKit1 = "";
- }
- if (isset ($_POST['LightingKit2']))
- {
- $LightingKit2 = $_POST['LightingKit2'];
- } else {
- $LightingKit2 = "";
- }
- echo "<p><span class='textblue'> $Aputure </span></p>";
- echo "<p><span class='textblue'> $Bescore </span></p>";
- echo "<p><span class='textblue'> $Dedo </span></p>";
- echo "<p><span class='textblue'> $Halogen </span></p>";
- echo "<p><span class='textblue'> $Keno </span></p>";
- echo "<p><span class='textblue'> $LightingKit1 </span></p>";
- echo "<p><span class='textblue'> $LightingKit2 </span></p>";
- ?>
- <br /><br /><input type="submit" value="Submit SQL Statements" />
- <?php
- $outputDisplay .= "<br /><br /><b>Number of Rows in Results: $myrowcount </b><br /><br />";
- echo $outputDisplay;
- ?>
- </body>
- </form>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement