Jump to content

PHP & MYSQL if then else statement


chrishawkins

Recommended Posts

Hello,

 

I have been able to put together some php code that shows a daily sales report of items that have been sold that day. The code selects from a table in my database, looks for the value under payment_status and when the value is confirmed it echos the results.

 

However, what I need to do now, is when it finds that the payment_status is confirmed and after it has been displayed to me, I need it to update the field named printed in that table to a value I set (i.e. printed). Also, the next time I run the script, I will need for it to do the same thing, only I will need it to now look for the payment_status='confirmed' as well as printed='printed' and only echo the results of payment_status='confirmed' if printed="null".

 

Can someone help me out with this?

 

Here is the code I have thus far;

 

<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

$result = mysql_query("SELECT * FROM auction_winners
WHERE payment_status='confirmed' ORDER BY bid_amount");

echo "<table border='1'>
<tr>
<th>Auction ID</th>
<th>Bid Amount</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['auction_id'] . "</td>";
  echo "<td>" . $row['bid_amount'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

Link to comment
https://forums.phpfreaks.com/topic/183321-php-mysql-if-then-else-statement/
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.