Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Select Department <font color='red'>*</font> </b> <?php
- $con=mysqli_connect("localhost","username","password","database_name");
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- $result1 = mysqli_query($con,"SELECT * FROM dept");
- echo "<select>";
- while($drop = mysqli_fetch_array($result1))
- {
- echo "<option>" . $drop['department'] . "</option>";
- }
- echo "</select>";
- mysqli_close($con);
- ?>
- <form class="appnitro" method="post" action="">
- <div class="form_description">
- <center><h2>NOMINATE ENTRY</h2></center>
- <p></p>
- </div><center>
- <b>Department     </b> <?php
- $con=mysqli_connect("localhost","username","password","dbname");
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- $result1 = mysqli_query($con,"SELECT * FROM dept");
- echo "<select name='department'>";
- while($drop = mysqli_fetch_array($result1))
- {
- echo "<option value='".$drop['department']."'>" . $drop['department'] . "</option>";
- }
- echo "</select>";
- mysqli_close($con);
- ?><p></center>
- <ul><center>
- <li class="buttons"><button type="submit" formaction="echo.php">Go</button></center></li>
- </ul>
- </form>
- Department     : <?php session_start(); $result=$_SESSION['department']; echo " ". $result; ?>
- Select Department <font color='red'>*</font> </b>
- <form name ="form1" action="" method="post"> /* You can remove this if you already have a form */
- <?php
- $con=mysqli_connect("localhost","username","password","database_name"); // replace for you own.
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- $result1 = mysqli_query($con,"SELECT * FROM dept");
- echo "<select name='department_name'>";
- while($drop = mysqli_fetch_array($result1))
- {
- echo "<option value='".$drop['department']."'>" . $drop['department'] . "</option>"; /* I would recommend changing the $drop['department'] in to the primary key from your table dept for example $drop['id'] */
- }
- echo "</select>";
- mysqli_close($con);
- ?>
- <input type="submit" value="Submit" name="submit">
- </form>
- <?php
- IF(isset($_POST['submit'])){
- echo "<b>Selected department: </b>".$_POST['department_name'] ;
- } /* This a test to see if you dropdown list works. */
- ?>
- CREATE TABLE dept (
- id int auto_increment primary key,
- department varchar (30)
- );
- INSERT INTO dept (department)
- VALUES ('department foo'), ('department foobar');
- <form action="myfile.php" method="post">
- <select name="mydropdown">
- <option value="a">A</option>
- <option value="b">B</option>
- </select>
- <input type="submit" value="Submit">
- </form>
- <?php
- $x = $_POST['mydropdown'];
- ?>
- <form class="appnitro" method="post" action="">
- <div class="form_description">
- <center><h2>NOMINATE ENTRY</h2></center>
- <p></p>
- </div><center>
- <b>Department     </b> <?php
- $con=mysqli_connect("localhost","username","password","dbname");
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- $result1 = mysqli_query($con,"SELECT * FROM dept");
- echo "<select name='department'>";
- while($drop = mysqli_fetch_array($result1))
- {
- echo "<option value='".$drop['department']."'>" . $drop['department'] . "</option>";
- }
- echo "</select>";
- mysqli_close($con);
- ?><p></center>
- <ul><center>
- <li class="buttons"><button type="submit" formaction="echo.php">Go</button></center>
- </li>
- </ul>
- </form>
- <h3>Department     : <?php $dept = $_POST['department']; echo " ". $dept; ?> </h3>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement