I am stumped on a project for a receiving system. I'm not sure how to handle
receiving more than one line item. I can UPDATE ... WHERE id=$detid when I
have 1 item, but how would I get the SQL to fire X times depending on the
number of line items I have AND UPDATE the appropriate record.

Currently I have the following:

index.php        ->        results.php        ->        recv.php
Search for         |    Results of PO        |    Page to receive/back order
PO  ($ponum    |    Search                  |    items.
or $vendor)

The code below displays the line items from the PO:

$myServer = "myserver";
$myUser = "login";
$myPass = "password";
$myDB = "db";

$s = @mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");

$d = @mssql_select_db($myDB, $s)
or die("Couldn't open database $myDB");

$sql="SELECT tbl_po.poid, tbl_po.vend_name, tbl_podet.qty,
tbl_podet.unitqty, tbl_podet.um, tbl_podet.partnum, tbl_podet.partdesc FROM
tbl_po INNER JOIN tbl_podet ON tbl_po.poid = tbl_podet.ponum WHERE

$result = mssql_query($sql);
$numRows = mssql_num_rows($result);
[HTML Table header]
while($row = mssql_fetch_array($result)) {

echo "<tr align=center valign=top>";
echo "<td align=center>" . $row[0] . "</td>";
echo "<td align=center>" . $row[1] . "</td>";
echo "<td align=center>" . $row[2] . "</td>";
echo "<td align=center>" . $row[3] . "</td>";
echo "<td align=center>" . $row[4] . "</td>";
echo "<td align=left>" . $row[5] . "</td>";
echo "<td align=left>" . $row[6] . "</td>";
echo "<td align=center><input type=\"text\" name=\"recvd\"></td>";
echo "<td align=center><input type=\"text\" name=\"bkord\"></td>";
echo "</tr>";
echo "</font>";
echo "</form>";
echo "</table>";
echo "<input type=\"submit\" name=\"Receive\" value=\"Receive\">";

The last 2 boxes in the table are for Recvd qty and Back Order Qty. The
problem is I could have 1 line item or I could have 10 line items. So if I
have 1 item and my SQL is "UPDATE tbl_podetail SET bkorder=$bkord WHERE
id=$detid" that will work fine, but if I have 10 items, the same UPDATE
statement will only update the LAST $detid, it won't fire 10 times for item.
I could add another column with a button next to each line item to save the
changes, but would (for simplicity) rather have the one "Receive" button.

Mike Smith

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to