Vote count:
0
I am doing a quiz generator with different question categories (Category: English, Math, Programming etc.), and I have to set the number of items for each category.
I used this block of codes to retrieve data from tbl_category:
SetItemLimit.php
<?php
$con=mysqli_connect("localhost","root","admin","learning_assessment") or die("Cannot connect to database!");
$sql="select * from tbl_category;";
$rs=mysqli_query($con,$sql);
$rows=mysqli_fetch_array($rs);
?>
<html>
<head></head>
<body>
<form action="SetItemLimit.php" method="post">
<table border="1">
<tr>
<th>Category</th>
<th>Number of Items</th>
</tr>
<?php do{?>
<tr>
<td><input type="text" value="<?php echo $rows['category'];?>" readonly="readonly" /></td>
<td><input type="text" name="perCatLimit" /></td>
</tr>
<?php }while($rows=mysqli_fetch_array($rs));?>
</table>
TOTAL NUMBER OF THE TEST ITEMS: <input type="text" name="numQ"/><br />
<input type="submit" name="SetItemLimit" value="SET ITEM LIMIT" />
</form>
</body>
</html>
What I wanted to happen is, when I set the number of items for each category and clicked submit button(SetItemLimit)-- the values will be added up and display to textbox(numQ).
<?php
if(isset($_POST['SetItemLimit'])){
}
can I use
array_sum()
?
asked 48 secs ago
How to add input values using array_sum, when my input data came from a loop?
Aucun commentaire:
Enregistrer un commentaire