Jump to content

Insert Drop Down values into Database


svabhishek

Recommended Posts

Hello everyone ... I am trying out something similar too but just cant get it to work :(

 

 

The code I have been using is as follows :

 

*    My database is FB and the table in it is profs. The field in profs is rating

**  The include/connection.php file is absolutely fine and it also echo me that the connection to the database has been successful

 FOR exp.php

			<?php include 'includes/connection.php'; ?>

				<h2>POST</h2>
				<form action="exp_process.php" method="post">
			    <select name="rating">
		                          <option value="1" selected="selected">1</option>
		                          			                          
		        <?php     
		                          for($i=2; $i<=10 ; $i++) {
		                          	echo '<option value="'.$i.'"> '.$i.' </option>';
		                          }
				?>			                          
		        </select><br>
                    <input type="button" value="submit" />
                </form>

 

 FOR exp_process.php

			<?php include 'includes/connection.php'; ?>		
			<?php

						$rating = $_POST['rating'];
						$query = "INSERT INTO `profs` (`rating`) VALUES (`rating`)";
						$result = mysql_query($query, $connection);

						if ($result) {
							// Success!
							echo " Success ";							
						} else {
							// Display error message.
							echo "<p>Updation Failed</p>";
							echo "<p>" . mysql_error() . "</p>";							
						}							

					?>

 

I tried to put in values to buttons and tried everything but dont know why but just can't get it to work the way it should. Any kind of help would be appreciated :) Thank you :)

Link to comment
https://forums.phpfreaks.com/topic/243813-insert-drop-down-values-into-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.