Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.