http://www.koolfree.com/ImageUpload/uploads/1340729929.jpg(テーブル画像)
こんにちは、私は画像にリンクしました(10未満のレピュテーションのためにstackoverflowがアップロードを許可しなかったため)、9列と3行のテーブルがあり、テーブルがデータベースとすべてに接続されていることがわかりますテーブルの値はデータベースに保存されます。
ご覧のとおり、合計の最後の列には、日数と給与の値の乗算結果を行ごとに個別に表示したいと思います。
例えば
user456は30日間働いており、給与は100なので、 30に100を掛けて結果、つまり3000を生成し、結果を合計<>金額の最後の列に表示する必要があります。
同様に、
user123は30日間働いており、給与は250なので、 30に250を掛けて結果、つまり7500を生成し、結果を合計<>金額の最後の列に表示する必要があります。
私はあなたの援助のために表と共有で次のコードを使用しました。
<?php
/*
VIEW.PHP
Displays all data from 'accounts' table
*/
// connect to the database
include('connect-db.php');
// get results from database
$result = mysql_query("SELECT * FROM accounts")
or die(mysql_error());
// display data in table
echo "<p><b>View All</b> | <a href='view-paginated.php?page=1'>View Paginated</a></p>";
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>No</th> <th>Name & ID</th> <th>Days</th> <th>OverTime</th> <th>Date</th> <th>Salary</th> <th>Edit</th><th>Delete</th><th>Total</th></tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['id'] . '</td>';
echo '<td>' . $row['keywords'] . '</td>';
echo '<td>' . $row['title'] . '</td>';
echo '<td>' . $row['description'] . '</td>';
echo '<td>' . $row['date'] . '</td>';
echo '<td>' . $row['salary'] . '</td>';
echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>';
echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>';
echo '<td><>amount</a></td>';
echo "</tr>";
}
// close table>
echo "</table>";
?>
必要な結果を生成するために、コードにどのような追加または変更を加える必要があるか教えてください。
http://www.koolfree.com/ImageUpload/uploads/1341093148.jpg
スクリーンショットのリンクを添付しました。スクリーンショットをご覧になり、ユーザーIDごとに複数のジョブを追加する方法を教えてください。