i have an html survey and the answers are stored in variables which should be loaded into the database via PHP.
For example, this is how questions (part of a table) that you can fill looks like in HTML:
<td style="padding-top: 10px;" colspan="9"> Question1:
<p style="text-align:left;"><textarea name="tag1" cols="80" rows="6"
style="border: 1px solid #D0D0D0;"></textarea></p>
</td>
<td style="padding-top: 10px;" colspan="9"> Question2:
<p style="text-align:left;"><textarea name="tag2" cols="80" rows="6"
style="border: 1px solid #D0D0D0;"></textarea></p>
</td>'
The PHP code:
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$tag1 = $_POST["tag1"];
$tag2 = $_POST["tag2"];
$sql = "INSERT INTO survey (tag1, tag2)
VALUES ('$tag1','$tag2')";
if (mysqli_query($conn, $sql)) {
echo "";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}'
So the textarea name="tag1" ... in html loads the answer of a user to the database column named tag1 by PHP.
The problem is i cannot add too many items to the bracket in the PHP INSERT code (like tag1, tag2, tag3...) because the characters are limited.
It is a problem due to the numbers of questions i should include. And if i create two separate command it loads to two different rows in the database which looks confusing. One person's answers should be appear in one row. (in phpmyadmin)
How can i solve it? what should i change?