spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

submit multiple values from a textfield with the same name


As requested, here is the full code. I added a new field "score" to show you how to add new fields.

<form method="post" name="form1"
id="form1" action="test.php">
  <input type="text" name="studentname[]"
value="wole" size="32" required="required" />
  <input type="text" name="course[]"
value="100" size="32" required="required" />
  <input type="text" name="score[]" value="100"
size="32" required="required" />
  <input type="text" name="studentname[]"
value="yetunde" size="32" required="required"
/>
  <input type="text" name="course[]"
value="200" size="32" required="required" />
  <input type="text" name="score[]" value="100"
size="32" required="required" />
</form>


<?php
$con=mysqli_connect
("localhost","root","famakin","results");
//Checkconnection
if(mysqli_connect_errno())
{
   
echo"FailedtoconnecttoMySQL:".mysqli_connect_error();
}
foreach($_POST['studentname'] as $idx =>
$studentname) {
    $sql="INSERT INTO records(studentname, 
course, score)VALUES('" . $studentname . "', '" .
$_POST['course'][$idx] . "', '" .
$_POST['score'][$idx] . "')";
    if(!mysqli_query($con,$sql))
    {
        die('Error:'.mysqli_error($con));
    }
}


echo '<META HTTP-EQUIV="Refresh" Content="0;
URL=result.php">';
mysqli_close($con);
?>

Categories : PHP

Related to : submit multiple values from a textfield with the same name
ExtJs: Manually fire paste event in textfield when that textfield is focused
It looks like the object firing the event is different than the object listening for the event. fld.on('paste', me.pasteFromClipboard,fld); fld.on('click', function(evt,target){ fld.fireEvent('paste'); // Trigger Paste Event. },fld); Now, both the firing and listening is tied to the fld

Categories : Javascript
Swift: UITextField IBAction - EditingChanged - Button stays enabled, even though textfield values are changed?
Try adding else statements and changing them back to not being enabled. @IBAction func calorieNumberEditingChanged(sender: AnyObject) { // If both variables are true and the text fields contain integers, enable button if self.yourWeightFilled && self.calorieNumberFilled { self.calculateButton.enabled = true } else { self.calculateButton.enabled = false } }

Categories : IOS
how to keep mark dynamically check boxes values after form submit
you should create an array $arrUserDtls["userid"] = {user_permission_name}. instead of <?php if($post['userperm']) { echo " checked=checked'"; } ?>> Please use this: <?php if($arrUserDtls[$values] == $values['permname']) { echo " checked=checked'"; } ?>>

Categories : Javascript
CakePHP 1.3: Make the confirm window with input values when submit form
You can achieve this using Jquery. Collect the values of all the inputs of form in an array. $('#myForm').submit(function() { var $inputs = $('#myForm :input'); var values = {}; $inputs.each(function() { values[this.name] = $(this).val(); $('#'+this.name).text(values[this.name]); if(this.name != 'submit'){ $(this).hide(); } });

Categories : PHP
How to handle multiple submit buttons in an angularjs form
As I see it, you have two options: 1: Use an ngClick event on the "save and add another" button and remove the "type='submit'" portion. Then in whatever function you call gor the ngClick, you can save and then reset the values, calling save() within that function. 2: Remove the ngSubmit altogether and just use ngClicks for both buttons.

Categories : Javascript
Recently Add
array_slice, implode, explode, count, for just a string permutation?
How to include a php file from parentdomain?
PHP / MySQL Order By Date & Random
Date and time store error in mysql and php
sorting a numeric php array
phpmailer debug output to html variable
Installing PHP YAML Extension with XAMPP on Windows
how insert data from android to wamp phpmyadmin?
wordpress - Big post IDs, is it Okay in the future?
PHP Change Array Order for Parent-Child Relation
Order by custom metabox value for date in get_posts
error rendering a sitemap with laravel
mysqli INSERTO query blank rows
Laravel error with 404 page
my custom function not working
PHP built-in server error log location
PHP: Appending a class to an include for specific pages
Check array Key Value in included file in PHP
Php Shuffling and inside a Php
PHP pass by reference
Get Facebook Photos without access token
PHP + MySQL No output of data after space in text input value
Parse XML using PHP with multiple namespaces
How do I call SOAP methods via PHP?
Laravel :: Routes Vs. Controller
Twitter Bootstrap navigation tab with does not work
Save content of table to a variable
Link a PHP file to an AJAX request in Magento
Why does my redirect works randomly
php curl_exec returns empty
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.