may project kasi kami evaluation system na web. nag select ako ng lahat ng questions sa database at nilagay ko sa datatable tapos each question meron syang radio button na may value na 1, 2, 3, 4, 5.. ang problema is hindi ko alam kung paano sya iinsert sa database. ilang araw na ako na stuck sa problemang ito d ko pa din na sosolusyunan pa help naman po eto po codes ko..
<?php
$sql = "SELECT * from question where category='A' order by id ASC";
$result = mysqli_query($con, $sql);
if(mysqli_num_rows($result) != 0)
{
while($row=mysqli_fetch_array($result))
{
$id = $row['id'];
$category = $row['category'];
$question = $row['question'];
echo "<tr>
<td>$question</td>
";
?>
<td width = "25%">
<center>
<input type="radio" name="q[<?php echo $id;?>]" id="inlineoptionsRadios1" class="first" value="1 - No idea" required>1
<input type="radio" name="q[<?php echo $id;?>]" id="inlineoptionsRadios2" class="first" value="2 - Known little about it" required>2
<input type="radio" name="q[<?php echo $id;?>]" id="inlineoptionsRadios3" class="first" value="3 - Familiar with it" required>3
<input type="radio" name="q[<?php echo $id;?>]" id="inlineoptionsRadios4" class="first" value="4 - Confident to talk about it" required>4
<input type="radio" name="q[<?php echo $id;?>]" id="inlineoptionsRadios5" class="first" value="5 - Can apply it to work/ output deliverables" checked>5
</center>
</td>
<?php
} }
?>
</tr>
</table>
<center>
<input type="submit" name="evaluate" class="btn btn-primary btn-large" value="Submit" />
</center>
</form>
<?php
if (isset($_POST['evaluate'])) {
$subjectcode1 = $_GET['subjectcode'];
$professor = $row['professor'];
$session = $_SESSION['studentnumber'];
$q = $_POST['q'.$id];
$answers = array($q => $value);
foreach ($answers as $q => $value){
echo $value;
$sql = "INSERT INTO studentresult (professor, rater, q1)
VALUES('$subjectcode1','$session', '$value')";
if (mysqli_query($con, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
mysqli_close($con);
}
}
?>
sana po may makatulong malapit na kasi yung defense namin ngayun monday na
<?php
$sql = "SELECT * from question where category='A' order by id ASC";
$result = mysqli_query($con, $sql);
if(mysqli_num_rows($result) != 0)
{
while($row=mysqli_fetch_array($result))
{
$id = $row['id'];
$category = $row['category'];
$question = $row['question'];
echo "<tr>
<td>$question</td>
";
?>
<td width = "25%">
<center>
<input type="radio" name="q[<?php echo $id;?>]" id="inlineoptionsRadios1" class="first" value="1 - No idea" required>1
<input type="radio" name="q[<?php echo $id;?>]" id="inlineoptionsRadios2" class="first" value="2 - Known little about it" required>2
<input type="radio" name="q[<?php echo $id;?>]" id="inlineoptionsRadios3" class="first" value="3 - Familiar with it" required>3
<input type="radio" name="q[<?php echo $id;?>]" id="inlineoptionsRadios4" class="first" value="4 - Confident to talk about it" required>4
<input type="radio" name="q[<?php echo $id;?>]" id="inlineoptionsRadios5" class="first" value="5 - Can apply it to work/ output deliverables" checked>5
</center>
</td>
<?php
} }
?>
</tr>
</table>
<center>
<input type="submit" name="evaluate" class="btn btn-primary btn-large" value="Submit" />
</center>
</form>
<?php
if (isset($_POST['evaluate'])) {
$subjectcode1 = $_GET['subjectcode'];
$professor = $row['professor'];
$session = $_SESSION['studentnumber'];
$q = $_POST['q'.$id];
$answers = array($q => $value);
foreach ($answers as $q => $value){
echo $value;
$sql = "INSERT INTO studentresult (professor, rater, q1)
VALUES('$subjectcode1','$session', '$value')";
if (mysqli_query($con, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
mysqli_close($con);
}
}
?>
sana po may makatulong malapit na kasi yung defense namin ngayun monday na