Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>[UPDATE] TRY THIS:</h3> <p>Send your values from the form as arrays as access the second input. If not, your record would get overwritten. You can't really have two form fields with the same name except they form an array. This should be your best option. Here we are storing both values in same table in two columns.</p> <h3>Your Form</h3> <pre><code>&lt;form action="add.php" method="post" name="verify"&gt; &lt;font color="#FFFF00"&gt;Name:&lt;/font&gt; &lt;input type="text" name="FistName[0]" /&gt; &lt;font color="#FFFF00"&gt;Name:&lt;/font&gt; &lt;input type="text" name="FirstName[1]"/&gt; &lt;input type="submit" value="add" name="verify"/&gt; </code></pre> <h3>Use this to add textbox 2 into database</h3> <pre><code>&lt;?php $names = $_POST["FirstName"]; $FirstName_1 = mysql_real_escape_string($names[0]); $FirstName_2 = mysql_real_escape_string($names[1]); $query = "INSERT INTO biodata (FirstName_1, FirstName_2) VALUES ('" . $FirstName_1 . "', '" . $FirstName_2 . "') "; $result = mysql_query($query); ?&gt; </code></pre> <h3>Use this to display from database</h3> <pre><code>&lt;?php $query = "SELECT * FROM biodata"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)){ ?&gt; &lt;tr&gt;&lt;td&gt;&lt;?php echo $row["FirstName_1"];?&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p> </p> <h3>To add two or more values to a database, follow this example in w3schools using mysqli (Note mysql is deprecated).</h3> <pre><code>&lt;?php //Filename: insert.php $con=mysqli_connect("example.com","peter","abc123","my_db"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO Persons (FirstName, LastName, Age) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[age]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error()); } echo "1 record added"; mysqli_close($con); ?&gt; </code></pre> <p>Your form:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;form action="insert.php" method="post"&gt; Firstname: &lt;input type="text" name="firstname"&gt; Lastname: &lt;input type="text" name="lastname"&gt; Age: &lt;input type="text" name="age"&gt; &lt;input type="submit"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Run a simple course here:</p> <p><a href="http://www.w3schools.com/php/php_mysql_insert.asp" rel="nofollow">http://www.w3schools.com/php/php_mysql_insert.asp</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload