mOrloff
09-22-2009, 05:20 PM
There has to be a better way to do this (not to mention that I'm getting an error).
I am trying to get some pricing info from our DB in this fashion:
If there is no ListPrice (that part being previous the snippet below) check for SalesHistory.
If no sales history, then look for quote history.
If no quote history, then look for a stockline suggested sellPrice.
Here's what I've got right now:
...
while ($row = MySQL_fetch_assoc($results))
{ // assign values to vars
$pID = $row["partID"];
// Define components for use in Query
$select ="partID";
$from ="SOItem";
$where ="SOItem.partID=$pID";
$result= qryFunc($select, $from, $where);
if($result)
{ // get min sales history x 1.2
$select ="MIN(SOItem.unitAmount), MIN(SOItem.unitAmount)*2";
$from ="SOItem";
$where ="SOItem.partID=$pID";
$result= qryFunc($select, $from, $where);
$value=MySQL_fetch_assoc($results);
echo "<pre>"; print_r($value); echo "</pre>";
}else{// go into quote history loop (lowest qt $)
$select ="partID)";
$from ="QuoteItem";
$where ="QuoteItem.partID=$pID";
$result= qryFunc($select, $from, $where);
if($result)
{ $select ="MIN(QuoteItem.price), max(QuoteItem.price)";
$from ="QuoteItem";
$where ="QuoteItem.partID=$pID";
$result= qryFunc($select, $from, $where);
$value=MySQL_fetch_assoc($results);
echo "<pre>"; print_r($value); echo "</pre>";
}
}else{// go to the stockline for pricing (highest s.sellPrice)
$select ="";
$from ="";
$where ="";
$result= qryFunc($select, $from, $where);
if($result)
{ $select ="MAX(Stockline.sellPrice), min(Stockline.sellPrice)";
$from ="Stockline";
$where ="Stockline.partID=$pID";
$result= qryFunc($select, $from, $where);
$value=MySQL_fetch_assoc($results);
echo "<pre>"; print_r($value); echo "</pre>";
}
}
Is there a better way to do this rather than running a complete query under the else, then running another query in the if($result)?
Thanks-a-bunch,
~ Mo
I am trying to get some pricing info from our DB in this fashion:
If there is no ListPrice (that part being previous the snippet below) check for SalesHistory.
If no sales history, then look for quote history.
If no quote history, then look for a stockline suggested sellPrice.
Here's what I've got right now:
...
while ($row = MySQL_fetch_assoc($results))
{ // assign values to vars
$pID = $row["partID"];
// Define components for use in Query
$select ="partID";
$from ="SOItem";
$where ="SOItem.partID=$pID";
$result= qryFunc($select, $from, $where);
if($result)
{ // get min sales history x 1.2
$select ="MIN(SOItem.unitAmount), MIN(SOItem.unitAmount)*2";
$from ="SOItem";
$where ="SOItem.partID=$pID";
$result= qryFunc($select, $from, $where);
$value=MySQL_fetch_assoc($results);
echo "<pre>"; print_r($value); echo "</pre>";
}else{// go into quote history loop (lowest qt $)
$select ="partID)";
$from ="QuoteItem";
$where ="QuoteItem.partID=$pID";
$result= qryFunc($select, $from, $where);
if($result)
{ $select ="MIN(QuoteItem.price), max(QuoteItem.price)";
$from ="QuoteItem";
$where ="QuoteItem.partID=$pID";
$result= qryFunc($select, $from, $where);
$value=MySQL_fetch_assoc($results);
echo "<pre>"; print_r($value); echo "</pre>";
}
}else{// go to the stockline for pricing (highest s.sellPrice)
$select ="";
$from ="";
$where ="";
$result= qryFunc($select, $from, $where);
if($result)
{ $select ="MAX(Stockline.sellPrice), min(Stockline.sellPrice)";
$from ="Stockline";
$where ="Stockline.partID=$pID";
$result= qryFunc($select, $from, $where);
$value=MySQL_fetch_assoc($results);
echo "<pre>"; print_r($value); echo "</pre>";
}
}
Is there a better way to do this rather than running a complete query under the else, then running another query in the if($result)?
Thanks-a-bunch,
~ Mo