Bifter Posted October 28, 2008 Share Posted October 28, 2008 Hiya all, Struggling a bit here; would really appreciate a little help - recon you guessed that tho.... <?php mysql_select_db("ipendpoi_Purchase", $conn); $result = mysql_query("SELECT * FROM po ORDER BY number DESC"); echo "<table width='100%' border='1'> <tr> <th>Date</th> <th>PO Number</th> <th>Requester</th> <th>Amount</th> <th>Vendor</th> <th>Department</th> <th>End User</th> <th>Invoiced</th> </tr>"; $rowclass = 0; while($row = mysql_fetch_array($result)) { echo "<tr class = row" . $rowclass . ">"; echo "<td>" . "<div align=\"center\">" . $row['date'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . "<a href=\"upload_directory/Purchase-Order-" . $row['number'] . ".pdf\">" . $row['number'] . "</a>" . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['requester'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . "£" . $row['amount'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['vendor'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['department'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['End_User'] . "</div>" . "</td>"; echo "</tr>"; $rowclass = 1 - $rowclass; } echo "</table>";mysql_close($conn); ?> This basically displays a list of purchase orders, there are a couple of thing I need to add - with a little help from you guys: 1: Incorporate a tick box that will indicate whether that PO has a corresponding invoice, the SQL table has an invoiced Column. 2: Display the total of the Amount column. Thank in advance, B. Quote Link to comment https://forums.phpfreaks.com/topic/130404-update-on-table/ Share on other sites More sharing options...
Barand Posted October 28, 2008 Share Posted October 28, 2008 try <?php mysql_select_db("ipendpoi_Purchase", $conn); $result = mysql_query("SELECT * FROM po ORDER BY number DESC"); echo "<table width='100%' border='1'> <tr> <th>Date</th> <th>PO Number</th> <th>Requester</th> <th>Amount</th> <th>Vendor</th> <th>Department</th> <th>End User</th> <th>Invoiced</th> </tr>"; $rowclass = 0; $total = 0; while($row = mysql_fetch_array($result)) { $chk = $row['invoiced'] = '1' ? 'checked=checked' : ''; $total += $row['amount']; echo "<tr class = row" . $rowclass . ">"; echo "<td>" . "<div align=\"center\">" . $row['date'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . "<a href=\"upload_directory/Purchase-Order-" . $row['number'] . ".pdf\">" . $row['number'] . "</a>" . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['requester'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . "£" . $row['amount'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['vendor'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['department'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . $row['End_User'] . "</div>" . "</td>"; echo "<td>" . "<div align=\"center\">" . "<input type='checkbox' $chk name='invoiced[]' value='Y'>" . "</div>" . "</td>"; echo "</tr>"; $rowclass = 1 - $rowclass; } echo "<tr class = row" . $rowclass . ">"; echo "<td colspan='4'>Total</td><td>$total</td><td colspan='4'> </td></tr>"; echo "</table>"; mysql_close($conn); ?> Quote Link to comment https://forums.phpfreaks.com/topic/130404-update-on-table/#findComment-676810 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.