Jump to content

Editing monthly sales figures..


ncncnc

Recommended Posts

Hi all,

 

I'm trying to make a webpage that allows the user to enter new sales figures for a certain product in a chosen month of a chosen year. I thought my code was correct but it doesn't really do anything. It just displays the table but it's not updated.

 

Can anybody spot an error?

 

   $describeQuery = "SELECT p.ID, p.NAME, dt.[Year], dt.[Month], dt.SalesVolume from Products p
join
(select ProductCode, sum(SalesVolume) as SalesVolume, [Month], [Year] from MonthlySales 
where [Year] = '$desiredYear' AND [Month] = '$desiredMonth' 
group by ProductCode, [Year], [Month])dt
on dt.ProductCode = p.ID";

$editQuery = "UPDATE MonthlySales SET SalesVolume = '$newSales'  WHERE Month ='$desiredMonth' AND Name = '$desiredProduct' AND Year = '$desiredYear'";

$results = sqlsrv_query($conn, $describeQuery);
$resultsx = sqlsrv_query($conn, $editQuery);

echo '<table border="1" BORDERCOLOR=Black>';
echo '<tr><th bgcolor = "LightBlue">Name</th><th bgcolor = "LightBlue" >ID</th> <th bgcolor = "LightBlue" >Sales</th><th bgcolor = "LightBlue" >Month</th> <th bgcolor = "LightBlue" >Year</th> </tr>';


while($row = sqlsrv_fetch_array($results, SQLSRV_FETCH_ASSOC)) 
  {   
  echo '<tr>';
echo '<td >' .$row['NAME'].'</td>';             
echo '<td>' .$row['ID'].'</td>'; 
echo '<td>' .$row['SalesVolume'].'</td>'; 
echo '<td>' .$row['Month'].'</td>'; 
echo '<td>' .$row['Year'].'</td>'; 
echo '</tr>';
} 

echo '</table>';

while($row = sqlsrv_fetch_array($resultsx, SQLSRV_FETCH_ASSOC)) 
  {
  }

sqlsrv_close($conn);

Link to comment
https://forums.phpfreaks.com/topic/260726-editing-monthly-sales-figures/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.