Displaying a sale price if something is on sale...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply

Who will you pick to be president?

Bush
0
No votes
Kerry
6
100%
 
Total votes: 6

zander213
Forum Newbie
Posts: 13
Joined: Mon Aug 23, 2004 1:46 pm

Displaying a sale price if something is on sale...

Post by zander213 »

Hi - I am designing my first php page and I have 2 colums for price, one for "price" and one for "saleprice"... as well as a column that tells me if an item is on sale "Y" or "N"...

Can someone help me write a simple script to display the "saleprice" and not the "price" if sale = Y...

I know it's really simple, but I am still a noobie, and need a little help. Here is my script for displaying the regular price:

<?php echo $row_shoes['price']; ?>

Any help would be GREATLY appreciated!

Thanks!
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

your a third of the way there.

Code: Select all

<?php
if($row_shoes['onSale']=='Y')
  echo $row_shoes['salePrice'];
else
  echo $row_shoes['price'];
?>
of course I have made a few assumptions but you should get the general idea.
Post Reply