Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/63566-help-with-update-query-for-table/
Share on other sites

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.

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;
} 

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.