Miss-Ruth Posted October 27, 2009 Share Posted October 27, 2009 My CODE: echo "<phone>".$line["phone"]."</phone>"; echo "<fax>".$line["fax"]."</fax>"; echo "<genemail>".$line["genemail"]."</genemail>"; echo "</item>"; I need the output to look like this. (all in one line including the spaces) Phone: 15614524 Fax: 13456789 Email: [email protected] How should the ode be amended? Link to comment https://forums.phpfreaks.com/topic/179163-solved-help-on-code-output/ Share on other sites More sharing options...
Bricktop Posted October 27, 2009 Share Posted October 27, 2009 Hi Miss-Ruth, You could do it a number of ways, the quickest (but ugliest) method is to use lots of . For example: echo "<phone>".$line["phone"]."</phone> "; echo "<fax>".$line["fax"]."</fax> "; echo "<genemail>".$line["genemail"]."</genemail>"; echo "</item>"; However, it would be much better to stick the items into DIVS and use CSS to add padding. For example: echo "<div class="phone"><phone>".$line["phone"]."</phone></div>"; echo "<div class="fax"><fax>".$line["fax"]."</fax></div>"; echo "<div class="genemail"><genemail>".$line["genemail"]."</genemail></div>"; echo "</item>"; Then, in your CSS file add: .phone{ padding-right: 10px; display: inline; } .fax{ padding-right: 10px; display: inline; } .genemail{ display:inline; } Hope this helps. Link to comment https://forums.phpfreaks.com/topic/179163-solved-help-on-code-output/#findComment-945238 Share on other sites More sharing options...
cags Posted October 27, 2009 Share Posted October 27, 2009 Or you could use css on the nodes themselves, you could probably eliminate the need for the divs. Link to comment https://forums.phpfreaks.com/topic/179163-solved-help-on-code-output/#findComment-945239 Share on other sites More sharing options...
Miss-Ruth Posted October 27, 2009 Author Share Posted October 27, 2009 Hello Bricktop! I picked the ugly way - But it disaplays "can not display the XML data" I don't know if this is helpful, but this is some XML data I want the output in one line as my previous post. Link to comment https://forums.phpfreaks.com/topic/179163-solved-help-on-code-output/#findComment-945241 Share on other sites More sharing options...
Bricktop Posted October 27, 2009 Share Posted October 27, 2009 Whoops! I didn't realise this was XML data. I would recommend you read this article which shows how to style your XML output. Hope this helps. Link to comment https://forums.phpfreaks.com/topic/179163-solved-help-on-code-output/#findComment-945242 Share on other sites More sharing options...
Miss-Ruth Posted October 27, 2009 Author Share Posted October 27, 2009 Thanks Bricktop!!! Sorry! I didn't know that's important. I came here expecting a quick answer rather than reading since I've got load of work to finish today. It would be great if someone could offer me with a final code! If no responses I'll use your link to see how to write it. Link to comment https://forums.phpfreaks.com/topic/179163-solved-help-on-code-output/#findComment-945244 Share on other sites More sharing options...
Bricktop Posted October 27, 2009 Share Posted October 27, 2009 Hi Miss-Ruth, OK, first of all you need to link to a CSS file in your XML opener like so: <?xml-stylesheet href="style.css" type="text/css"?> Now, create a file called style.css and add the following: PHONE { padding-right: 10px; display:inline } FAX { padding-right: 10px; display:inline } GENEMAIL { display:inline } Remember to upload style.css to your server. Hope this helps. Link to comment https://forums.phpfreaks.com/topic/179163-solved-help-on-code-output/#findComment-945248 Share on other sites More sharing options...
Miss-Ruth Posted October 27, 2009 Author Share Posted October 27, 2009 GREAT!!!!!! Thanks Bricktop - <3 Link to comment https://forums.phpfreaks.com/topic/179163-solved-help-on-code-output/#findComment-945257 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.