Jump to content

Elements not spanning two lines


gwh

Recommended Posts

Hi everyone,

 

I have the following php code:

 

<?php 


$itemPriceBoth = $item['itemPriceBoth'];
$itemPriceFemale = $item['itemPriceFemale'];
$itemPriceMale = $item['itemPriceMale']; 


if ($itemPriceFemale > 0)
{ 	echo "<span> Ladies price: $</span>$itemPriceFemale"; 

	if ($itemPriceMale > 0)
	{ echo "<span> Men's price: $</span>$itemPriceMale";
	} 

	elseif (($itemPriceFemale > 0) && ($itemPriceMale > 0))

		{	echo "<span style='display: block; padding-top: 10px;'> Ladies price: $</span>$itemPriceFemale";
			echo "<span style='display: block; padding-top: 10px;'> Men's price: $</span>$itemPriceMale";

		}
} 


if ($itemPriceBoth > 0)
{ 	echo "<span> Price: $</span>$itemPriceBoth"; } 


?>

 

When the following two lines are output I need them to be on two separate lines, but when they're output they're sitting on the same line:

 

{	echo "<span style='display: block; padding-top: 10px;'> Ladies price: $</span>$itemPriceFemale";
			echo "<span style='display: block; padding-top: 10px;'> Men's price: $</span>$itemPriceMale";

		}

 

I thought the style='display: block;  would make the spans block level elements but this isn't happening.

 

Does anyone know what's wrong with the code?

 

Appreciate any help.

Link to comment
https://forums.phpfreaks.com/topic/192920-elements-not-spanning-two-lines/
Share on other sites

In case you want output look like this

 

Ledies price:$100
Men's price:$250

 

then try like so:

echo "<span style='display: block; padding-top: 10px;'> Ladies price: $".$itemPriceFemale."</span>";
echo "<span style='display: block; padding-top: 10px;'> Men's price: $".$itemPriceMale."</span>";

In case you want output look like this

 

Ledies price:$100
Men's price:$250

 

then try like so:

echo "<span style='display: block; padding-top: 10px;'> Ladies price: $".$itemPriceFemale."</span>";
echo "<span style='display: block; padding-top: 10px;'> Men's price: $".$itemPriceMale."</span>";

 

I tried the above code but this still hasn't helped - it's still on one line. I also tried a div which didn't work either. The code originally posted is inside an include file which is eventually inserted into a pair of <p> tags so I don't think the div tag's a very good idea:

 

<p><?php include(__ROOT__ . "/includes/item_price.inc.php"); ?></p>

 

I thought maybe it's got something to do with the rest of the code block since the following lines aren't being output:

 

if ($itemPriceMale > 0)

{ echo "<span> Men's price: $</span>$itemPriceMale";

}

 

Does anything else look wrong?

 

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.