samoht Posted August 6, 2007 Share Posted August 6, 2007 Hello Again, I could really use some help with this problem. I have a function: <?php function get_packages($pid) { $ProductId = $pid; $sql = mysql_query("SELECT DISTINCT pdp.PackageId, PackageType, RetailPrice, SellPrice, HoldPrice, Cost, Pcode FROM productpackaging pdp, packaging p WHERE pdp.ProductId = $ProductId AND pdp.PackageId = p.PackageId"); while($row = mysql_fetch_assoc($sql)) { $rows[] = $row; } return $rows; } Simple enough? And a table of prices (with 2 rows - one for retail and one for wholesale prices) <?php $ProductId = $row_rsProducts[ProductId]; $currentPackage = $_GET['PackageID']; $packages = get_packages($ProductId); $i = 0; ?> <table class="prices" width="350" border="0" cellpadding="0" cellspacing="0"> <tr> <td><?php echo "<table class=\"display\" width='300' border='0' cellpadding='0' cellspacing='0'> <tr class=\"d0\"> <th></th> <th align=\"center\">Retail</th> <th align=\"center\">Sell</th> <th align=\"center\">Hold</th> <th align=\"center\">Cost</th> </tr>"; for($n = 0; $n < 2; $n++) { echo "\n\t<tr class=\"d".($n & 1)."\">\n\t"; if($packages[$n]['Pcode']=='RT'){echo "<td>Retail</td>";}else {echo "<td>Wholesale</td>";} echo "<td>$" . $packages[$n]['RetailPrice'] . "</td>"; echo "<td>$" . $packages[$n]['SellPrice'] . "</td>"; echo "<td>$" . $packages[$n]['HoldPrice'] . "</td>"; echo "<td>$" . $packages[$n]['Cost'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> <td valign="bottom"> <table class="packagepic" width="75" align="right" border="0"> <tr> <td><?php ?></td> </tr><?php ?> <tr> <td><div align="center" style="font-size:smaller;"><?php echo $packages[$i]['PackageType']; ?></div></td> </tr> </table> Which displays like Wholesale Retail Sell Hold Cost Wholesale $6.25 $6.25 $6.25 $0 Wholesale $5.79 $5.79 $5.79 $0 Bulk Only the first column actually says; Retail Wholesale but I couldn't get that to display right in the post. Anyway where the table displays the PakageType (currently "Bulk") I would like to be able to let the user change that and have the table refresh with the proper prices for the new package Quote Link to comment https://forums.phpfreaks.com/topic/63566-help-with-update-query-for-table/ Share on other sites More sharing options...
DeepakJ Posted August 6, 2007 Share Posted August 6, 2007 UPDATE PackageID SET bulk=$bulk Where xxxx Quote Link to comment https://forums.phpfreaks.com/topic/63566-help-with-update-query-for-table/#findComment-316780 Share on other sites More sharing options...
samoht Posted August 6, 2007 Author Share Posted August 6, 2007 I'm sorry - I am not trying to do an UPDATE query but rather pass a variable to my query in my function. my page will be displaying several products (more than 1) in a repeating table. Inside each product I display this prices table which is based on the product id and the package - I want to be able to scroll through the different packages for each product and have the price table update accordingly. Product1 Prices ... Retail 5.50 Wholsale 4.25 Bulk Product2 Prices ... Retail 7.50 Wholsale 5.25 24ct. Quote Link to comment https://forums.phpfreaks.com/topic/63566-help-with-update-query-for-table/#findComment-316788 Share on other sites More sharing options...
DeepakJ Posted August 6, 2007 Share Posted August 6, 2007 Then make another parameter for the function and use that in the query. Quote Link to comment https://forums.phpfreaks.com/topic/63566-help-with-update-query-for-table/#findComment-316829 Share on other sites More sharing options...
samoht Posted August 6, 2007 Author Share Posted August 6, 2007 OK - but how do I get the user to be able to change this?? <?php function get_packages($pid, $pack) { $ProductId = $pid; $PackageId = $pack; $sql = mysql_query("SELECT DISTINCT pdp.PackageId, PackageType, RetailPrice, SellPrice, HoldPrice, Cost, Pcode FROM productpackaging pdp, packaging p WHERE pdp.ProductId = $ProductId AND pdp.PackageId = p.PackageId AND pdp.PackageId = $PackageId"); while($row = mysql_fetch_assoc($sql)) { $rows[] = $row; } return $rows; } Quote Link to comment https://forums.phpfreaks.com/topic/63566-help-with-update-query-for-table/#findComment-316869 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.