1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| <?php
function AddRow() {
require_once ('../mysqli_connect.php');
$output ='<tr>';
$output .= '<td><input type="text" name="fname" size="20" maxlength="50" value="" /></td>';
$output .='<td>';
$output .='<select name="fstatus" style="width: 150px">';
// Retrieve all the statuses of a functionality
$q = "SELECT F_status_ID, Functionality_status FROM fstatuses ORDER BY F_status_ID ASC";
$r = mysqli_query($dbc, $q);
if (mysqli_num_rows($r) > 0) {
while ($menu_row = mysqli_fetch_array($r, MYSQLI_NUM)) {
$output .= "<option value=\"$menu_row[0]\">$menu_row[1]</option>\n";
}
}
$output .= '</select>';
mysqli_free_result($r);
unset($menu_row);
$output .='</td>';
$output .= '<td> <textarea name="fdescription" rows="2" cols="30" wrap="hard" ></textarea> </td>';
$output .= '</tr>';
return $output;
}
?>
<?php
function CurrentTable($table){
foreach ($table as $id => $list) {
echo '<tr>';
foreach ($list as $k => $v ) {
echo '<td align="left"> ' . $v . '</td>';
}
echo '<td><a href= "delete.php?id=' . $id . '">Delete</a></td>';
echo '</tr>';
}
}
?>
<h1> Create an Item </h1>
<form action="test.php" method="post">
<input type="submit" Name= "Ajouter" Value="Ajouter">
<table align="center" border = "2" cellspacing ="0" cellpadding="3" >
<tr><td><b>Functionality Name:</b></td> <td><b>Description:</b></td> <td><b>Status:</b></td> </tr>
<?php
$id=0;
$table= array();
if (!isset ($_POST['Ajouter'])){
CurrentTable($table);
}
elseif (isset ($_POST['Ajouter'])){
$id += 1;
$op = AddRow();
echo $op;
$table = array($id => array("fname" => $_POST['fname'], "fdescription" => $_POST['fdescription'], "fstatus"=> $_POST['fstatus']));
echo $id;
CurrentTable($table);
var_dump ((unset) $op);
var_dump((unset) $_POST['Ajouter']);
}
?>
</table>
</form> |
Partager