Jump to content

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/130404-update-on-table/
Share on other sites

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);
?>

Link to comment
https://forums.phpfreaks.com/topic/130404-update-on-table/#findComment-676810
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.