Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

hide echo using ! not working

Engaged ,
Dec 18, 2013 Dec 18, 2013

i have two prices the price and a discount, some products have the discount a couple dont if they dont have the discount i want to have hide the price as below

<? if (!$row_rsProduct['Product'] == 'prod1'):

                    ?>

<?php echo DoFormatCurrency($row_rsProduct['Price'], 2, '.', '.', '£ ', ''); ?>

<?php endif; ?>

<?php echo DoFormatCurrency($row_rsProduct['Discount'], 2, '.', '.', '£ ', ''); ?>

TOPICS
Server side applications
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , Dec 19, 2013 Dec 19, 2013

Is there a reason you are wrapping every line of code in script tags?

Is prod1 a variable, a costant, or a literal? If a variable, begin with a dollar sign. If a constant, make it all caps (that's for the sake of convention) and don't wrap in single quotes. If a literal, then leave the way you had it. I suspect you intended a variable.

if ($row_rsProduct['Product'] != $prod1){

               echo DoFormatCurrency($row_rsProduct['Price'], 2, '.', '.', '£ ', '');

}

echo DoFormatCurrency($row_rsProduc

...
Translate
LEGEND ,
Dec 18, 2013 Dec 18, 2013

Show us an example of the output you are getting and include the value of the 'Product' field.

'prod1' seems like a funny way to determine if a product has a discount.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 19, 2013 Dec 19, 2013

Is there a reason you are wrapping every line of code in script tags?

Is prod1 a variable, a costant, or a literal? If a variable, begin with a dollar sign. If a constant, make it all caps (that's for the sake of convention) and don't wrap in single quotes. If a literal, then leave the way you had it. I suspect you intended a variable.

if ($row_rsProduct['Product'] != $prod1){

               echo DoFormatCurrency($row_rsProduct['Price'], 2, '.', '.', '£ ', '');

}

echo DoFormatCurrency($row_rsProduct['Discount'], 2, '.', '.', '£ ', '');

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 19, 2013 Dec 19, 2013

here is where all the code, a variable was not intented, it is an actual product name that needs to be used

$var1_rsProduct = "-1";

if (isset($_GET['productID'])) {

  $var1_rsProduct = $_GET['productID'];

}

mysql_select_db($database_event, $event);

$query_rsProduct = sprintf("SELECT * FROM eventAW13_Cat, eventAW13_products, eventAW13_Stock, eventAW13_SizeList WHERE eventAW13_products.catID = eventAW13_Cat.catID AND eventAW13_products.ProductID = eventAW13_Stock.ProductID AND eventAW13_Stock.SizeID = eventAW13_SizeList.SizeID AND eventAW13_products.ProductID = %s AND eventAW13_Stock.Stock != 0  ORDER BY eventAW13_Stock.StockID", GetSQLValueString($var1_rsProduct, "int"));

$rsProduct = mysql_query($query_rsProduct, $event) or die(mysql_error());

$row_rsProduct = mysql_fetch_assoc($rsProduct);

$totalRows_rsProduct = mysql_num_rows($rsProduct);

the actual product is "jumper red stripe"

><? if (!$row_rsProduct['Product'] == 'jumper red stripe'):

                    ?><?php echo DoFormatCurrency($row_rsProduct['Price'], 2, '.', '.', '£ ', ''); ?><?php endif; ?><?php echo DoFormatCurrency($row_rsProduct['Discount'], 2, '.', '.', '£ ', ''); ?>

in the database i have two columns the "Discount and the "Price" if something does not have a discount they have the same price in both so only need the discount one showing thus hide the "Price".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 19, 2013 Dec 19, 2013

I'll repeat my question from earlier:

"Show us an example of the output you are getting and include the value of the 'Product' field."

You haven't explained to us how this code is misbehaving. What's it doing?

Like Rob, I also don't understand why you are wrapping each line in script tags.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 19, 2013 Dec 19, 2013

Bregent,

I'm pretty sure I pointed him in the right direction. The condition of his if statement was wrong. He needs to make a little effort to look at the code I provided.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 19, 2013 Dec 19, 2013

sorry, your correct i didnt read the code you posted well enough, i put the exclamation mark in the wrong place and there is no reason for the extra script tags. i am cleaning my code up

thank you both for the help

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 19, 2013 Dec 19, 2013
LATEST

Glad you got it sorted out.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines