Jump to content

Need help revising code


gwh

Recommended Posts

Hi everyone,

 

I have the following code in an include file:

 

<?php 

//1=ladies, 2=mens, 3=both
$descAvailable = 0;
$ladiesDesc = $shirt['shirtDescLadies'];
$mensDesc = $shirt['shirtDescMen']; 


//Add 1 if ladies available – Will be set to 1 if only ladies available
if ($ladiesDesc != "")
{ $descAvailable = $descAvailable+1; } 

/*Add 2 if mens available
If ladies is available too this will now be set at 3 (both available)
Otherwise it will remain at 2 (mens available)*/
if ($mensDesc != "")
{ $descAvailable = $descAvailable+2; } 
//Show ladies description if descAvailable is set to ladies or both
if (($descAvailable == 1) || ($descAvailable == 3))
{
        if ($descAvailable == 3) // Only echo heading if available description is both
        { echo "<span style='display: block; padding-top: 10px;'> Ladies:</span>"; } 
        echo $ladiesDesc; //always echo this if both or ladies
} 
//Show mens description if descAvailable is set to mens or both
if (($descAvailable == 2) || ($descAvailable == 3))
{
        if ($descAvailable == 3)// Only echo heading if available description is both
        { echo "<span style='display: block; padding-top: 10px;'>Mens: </span>"; } 
        echo $mensDesc; //always echo this if both or mens
}
?>

 

I need the following line:

 

        { echo "<span style='display: block; padding-top: 10px;'> Ladies:</span>"; }

 

to insert an additional heading before the "Ladies:" heading.

 

I tried the following:

 

        { echo "<span style='display: block;>Description</span> . <span style='display: block; padding-top: 10px;'> Ladies:</span>"; }

 

but it didn't work.

 

Does anyone know what I'm doing wrong?

 

Appreciate any help.

Link to comment
https://forums.phpfreaks.com/topic/186149-need-help-revising-code/
Share on other sites

How do you mean it didnt work?

 

What was it supposed to do? If you want a newline, in html use '<br />', in plain text use '\n'.

 

Check over the HTML source output (right-click in IE/Mozilla and click 'View Source'). Make sure it's what you expect.

 

-CB-

In

{ echo "<span style='display: block;>Desc...

you have open single quotes.

Should be

{ echo "<span style='display: block;'>Desc...

Also, the period will be displayed literally (I'm not sure if that's what you're trying to accomplish) unless you also close and reopen the double quotes after the first </span>

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.