Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How not to show space


Salvo

Recommended Posts

Hi all

 

if not model is available, I don't want to show the 'CODE NO' below. How do I do that?

 

Thanks

Salvo

 

<?php

if (PRODUCT_LIST_MODEL) {

echo ' <tr>' . "n" .

' <td colspan="2" class="pageHeading">' . 'CODE NO.model' . $product_info_values['products_model'] . '</td>' . "n" .

' </tr>' . "n";

}

?>

Link to comment
Share on other sites

It might be me...

let refrace the question...

 

entering information into a field in a product, then that info will show up in the main catalog (product_info)...

 

now, if one doesn't enter anything into that field, of course will be nothing to show, but the space will be there.

 

example...

 

Information entered in field 1 here

empty field 2 (empty space)

informaiton entered in field 3 here

 

now, the empty field will show as a space...

 

my question was I don't want to show the space in between the field 1 and 3...

 

how?

 

Thanks

 

sorry if I didn't make myself undestood..

 

Salvo

Link to comment
Share on other sites

trim is a handy dandy command.

 

<?php echo field1 . ' ' . trim(field2) . ' ' . trim(field3); ?>

 

The two spaces between field1 and field2 and field2 and field3 will become 1 space if field2 is blank. :D

Link to comment
Share on other sites

trim is a handy dandy command.

 

<?php echo field1 . ' ' . trim(field2) . ' ' . trim(field3); ?>

 

The two spaces between field1 and field2 and field2 and field3 will become 1 space if field2 is blank. :D

 

 

there would show 2 fields details if entered, but 2 spaces if nothing there.

How would you implement the trim with this below?

 

 

<?php

if (PRODUCT_LIST_MODEL) {

echo ' <tr>' . "n" .

' <td colspan="2" class="pageHeading">' . 'CODE NO.model' . $product_info_values['products_model'] . '</td>' . "n" .

' </tr>' . "n";

}

?>

 

<?php

if (PRODUCT_LIST_MODEL2) {

echo ' <tr>' . "n" .

' <td colspan="2" class="pageHeading">' . 'CODE NO.model2' . $product_info_values['products_model2'] . '</td>' . "n" .

' </tr>' . "n";

}

?>

Link to comment
Share on other sites

Keep in mind that two spaces, three spaces, 10 spaces are 1 space unless you use  

 

I am not sure what that 'CODE NO.model' is suppose to be. Is that text? or a field or a constant or a constant plus a field from some array or what there?

 

I hate to be slow, but what do you want the output to look like and where is the output coming from?

 

If this is Text field field

 

Use 'CODE ' . trim(NO.model2 . ' ' . $product_info_values['products_model2'])

 

This way the text gives a space then ... added space is removed if one or both fields are empty by the trim.

Link to comment
Share on other sites

CODE NO.model would be text...

 

when there is a model code in the field, in the product_info would show like this:

 

CODE NO. 1234

 

If there is not code in the field, at moment It will show

 

CODE NO.

 

Without anything in the field... in few words, I don't want to show the CODE NO.(text) IF no model code is entered because I have added up to 15 fields but not all will have codes in them so I would end up with

 

Code no. 124

code no.

code no.

code no. 3455

code no. 321

 

 

idel would be:

 

code no. 124

code no. 3455

code no. 321

Link to comment
Share on other sites

can't you just see if the model has a value and print on that?

 

if ($product_model_nr) echo 'CODE.NO.bla';

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Link to comment
Share on other sites

HI there,

I am not at on my computer and I can't try it now, but is it the right way the one below?

 

if there is a value into the field, it will show all.

else will NOT show anything...

 

 

<?php

IF ($product_info_values)

{

if (PRODUCT_LIST_MODEL)

{

echo ' <tr>' . "n" .

' <td colspan="2" class="pageHeading">' . TEXT__MODEL_NO . $product_info_values['products_model'] . '</td>' . "n" .

' </tr>' . "n";

}

}

 

ELSE {

Echo ? ? . ?n?;

?>

Link to comment
Share on other sites

Just for the benefit of someone else with little experience like me interested in this little code.

 

for me it is very important because I have added 15 fields and finally I MADE it.. :-)

 

This code below is the correct and does NOT show a field in the product_info.php if that field is empty

 

<?php

if ($product_info_values['products_model'])

{

if (PRODUCT_LIST_MODEL) {

echo ' <tr>' . "n" .

' <td colspan="2" class="pageHeading">' . 'Text_MODEL_NO' . $product_info_values['products_model'] . '</td>' . "n" .

' </tr>' . "n";

}

}

else '';

?>

 

 

Thanks for your help

 

Salvo

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...