gwh Posted February 22, 2010 Share Posted February 22, 2010 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 More sharing options...
jl5501 Posted February 22, 2010 Share Posted February 22, 2010 { echo "<span style='display: block; padding-top: 10px;'> Ladies price: $</span>$itemPriceFemale<br />"; echo "<span style='display: block; padding-top: 10px;'> Men's price: $</span>$itemPriceMale"; } Link to comment https://forums.phpfreaks.com/topic/192920-elements-not-spanning-two-lines/#findComment-1016068 Share on other sites More sharing options...
gwh Posted February 22, 2010 Author Share Posted February 22, 2010 Thanks for the reply, You just added the <br /> right? I tried this and still no luck - they're both on the one line. I really thought the display: block would mark them on one line. Any other ideas? Link to comment https://forums.phpfreaks.com/topic/192920-elements-not-spanning-two-lines/#findComment-1016070 Share on other sites More sharing options...
sader Posted February 22, 2010 Share Posted February 22, 2010 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>"; Link to comment https://forums.phpfreaks.com/topic/192920-elements-not-spanning-two-lines/#findComment-1016073 Share on other sites More sharing options...
jl5501 Posted February 22, 2010 Share Posted February 22, 2010 well instead of the display:block <span> use a <div> and see if that helps Link to comment https://forums.phpfreaks.com/topic/192920-elements-not-spanning-two-lines/#findComment-1016076 Share on other sites More sharing options...
gwh Posted February 22, 2010 Author Share Posted February 22, 2010 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? Link to comment https://forums.phpfreaks.com/topic/192920-elements-not-spanning-two-lines/#findComment-1016081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.