usman07 Posted May 14, 2012 Share Posted May 14, 2012 I have an echo here, and not sure where about's I can put <br /> and want to be able to style it in the css (need to create a div class or something on it) Thank You echo 'address="' . parseToXML($row['address']) . '" '; Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/ Share on other sites More sharing options...
ManiacDan Posted May 14, 2012 Share Posted May 14, 2012 <br /> isn't special, it's just part of the string. echo '<br />address="' . parseToXML($row['address']) . '" <br />'; Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345402 Share on other sites More sharing options...
usman07 Posted May 14, 2012 Author Share Posted May 14, 2012 Thats doesn't seem to work, What i want is for the echo to be on the next line? i thort thats what <br /> is used for. Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345405 Share on other sites More sharing options...
ManiacDan Posted May 14, 2012 Share Posted May 14, 2012 Are you outputting this to a browser? <br /> is an HTML tag, it only works on HTML documents. Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345407 Share on other sites More sharing options...
usman07 Posted May 14, 2012 Author Share Posted May 14, 2012 Yeah its a browser and its actually a php page? that outputs on a html page Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345409 Share on other sites More sharing options...
ManiacDan Posted May 14, 2012 Share Posted May 14, 2012 Then what are you seeing on the screen? Are you seeing the <br> tags? What happens when you view the source of the page? Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345411 Share on other sites More sharing options...
usman07 Posted May 14, 2012 Author Share Posted May 14, 2012 Im doing for google maps which is used using php and mysql and my pin points showing on the map disappear. Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345416 Share on other sites More sharing options...
mrMarcus Posted May 14, 2012 Share Posted May 14, 2012 Im doing for google maps which is used using php and mysql and my pin points showing on the map disappear. Well, this could be due to a million different things. Are you using Firebug for Firefox? It will help you to drill down any formatting errors within javascript and such. The code you initially posted, is that within a 'createMarker()' sort of function? Can you post that function and any related code. Mentioning this was within Google Maps is the kind of info you really need to include at the beginning, and may not be a PHP issue at all. Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345438 Share on other sites More sharing options...
usman07 Posted May 14, 2012 Author Share Posted May 14, 2012 I don't think so, heres more of the code: // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '<marker '; echo 'name="' . parseToXML($row['name']) . '" '; echo 'address="' . parseToXML($row['address']) . '" '; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo 'type="' . $row['type'] . '" '; echo '/>'; } No im using the safari browser. Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345447 Share on other sites More sharing options...
ManiacDan Posted May 14, 2012 Share Posted May 14, 2012 You can't put HTML tags inside of HTML tags. Adding line breaks to this won't do any good. If you wish to add line breaks so the HTML source is prettier for some reason, use "\n": echo 'name="' . parseToXML($row['name']) . '" ' . "\n"; Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345449 Share on other sites More sharing options...
mrMarcus Posted May 14, 2012 Share Posted May 14, 2012 Didn't I already give you a working map example in that other thread? It's much less confusing than building the XML yourself. Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345451 Share on other sites More sharing options...
usman07 Posted May 15, 2012 Author Share Posted May 15, 2012 I did that but the ouput still remains the same, it doesnt have a line break? echo 'name="' . parseToXML($row['name']) . '" ' . "\n"; And yeah MrMarcus You did give me another way, but when I saw your reply i already got it all working with the google maps following their tutorial. I just want to know how to style it? Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345567 Share on other sites More sharing options...
mrMarcus Posted May 15, 2012 Share Posted May 15, 2012 I did that but the ouput still remains the same, it doesnt have a line break? echo 'name="' . parseToXML($row['name']) . '" ' . "\n"; The styling does not go in there. As was stated earlier, you cannot put HTML within HTML. That line of code is part of a block of code that is how your map reads the markers to be displayed: // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '<marker '; echo 'name="' . parseToXML($row['name']) . '" '; echo 'address="' . parseToXML($row['address']) . '" '; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo 'type="' . $row['type'] . '" '; echo '/>'; } The above outputs like so: <marker name="something" address="something" lat="something" lng="something" type="something"/> And you cannot put styling within. From there, the while() loop will iterate through all available 'markers' in the database, and generate the corresponding number of markers that will then be parsed by further code to be displayed on the map. What exactly are you trying to style? The InfoWindow when you click on a marker? Please be specific and show some code (you should have a [javascript] function that creates the markers, ie. CreateMarker(), or something similar). Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345569 Share on other sites More sharing options...
usman07 Posted May 15, 2012 Author Share Posted May 15, 2012 Yeah the information in the info window. I tried the <br/> in the javascript and it worked. So im guessing I can style using javascript? How can I give the javascript some sort of ID so I can style it in my css? function createMarker(point, name, address, type) { var marker = new GMarker(point, customIcons[type]); var html = "<b>" + name + "</b> <br/><br/>" + address; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345570 Share on other sites More sharing options...
mrMarcus Posted May 15, 2012 Share Posted May 15, 2012 Yeah the information in the info window. I tried the <br/> in the javascript and it worked. So im guessing I can style using javascript? How can I give the javascript some sort of ID so I can style it in my css? function createMarker(point, name, address, type) { var marker = new GMarker(point, customIcons[type]); var html = "<b>" + name + "</b> <br/><br/>" + address; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } Yes, that's it. Do all your styling within there. Have you tried it? Create a class/ID and swap out the <b> for <span class="your_class"> and see what happens. I just noticed this tutorial is for Gmaps V2. Version 2 is dated, and if not already, will soon be deprecated. If you plan on working with Google Maps in the future on other projects, get rid of V2 immediately and do not waste any more time. Move to V3. I strongly, strongly recommend you do so. It's faster, cleaner, and more scalable. The example I provided you in the other thread was V3. Mess around with my example map. You can use the exact same db table, and I believe my code was already setup using the same fields as your example. Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345573 Share on other sites More sharing options...
usman07 Posted May 15, 2012 Author Share Posted May 15, 2012 ahh ok where would I put the closing </span>? Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345576 Share on other sites More sharing options...
mrMarcus Posted May 15, 2012 Share Posted May 15, 2012 In place of the closing </b>. Seems you might be trying to sprint before you've learned to walk. var html = "<span class="my_class_to_do_something">" + name + "</span><br/><br/>" + address; Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345581 Share on other sites More sharing options...
usman07 Posted May 15, 2012 Author Share Posted May 15, 2012 Ok I did that but the map totally disapears? var html = "<span class="mapinfo">" + name + "</span> <br/><br/>" + address; Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345582 Share on other sites More sharing options...
mrMarcus Posted May 15, 2012 Share Posted May 15, 2012 Ok I did that but the map totally disapears? var html = "<span class="mapinfo">" + name + "</b> <br/><br/>" + address; My mistake. Either replace the double-quotes with single-quotes or escape the double-quotes. And you didn't replace the closing </b>. You know basic HTML, correct? var html = "<span class='mapinfo'>" + name + "</b> <br/><br/>" + address; Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345584 Share on other sites More sharing options...
usman07 Posted May 15, 2012 Author Share Posted May 15, 2012 Thanks Mate, really appreciate it. Would It be possible for me to add a image in there too? in the info window. So add the url of the images in my table and then somehow code it in the php file? Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345586 Share on other sites More sharing options...
mrMarcus Posted May 15, 2012 Share Posted May 15, 2012 Thanks Mate, really appreciate it. Would It be possible for me to add a image in there too? in the info window. So add the url of the images in my table and then somehow code it in the php file? Yes, you can add pretty much anything you want in there. Only one way to find out... try it. var html = "<img src='" + image + "'/> <span class='mapinfo'>" + name + "</span> <br/><br/>" + address; You must now add 'image' to your XML markup: // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '<marker '; echo 'name="' . parseToXML($row['name']) . '" '; echo 'address="' . parseToXML($row['address']) . '" '; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo 'type="' . $row['type'] . '" '; echo 'image"'. $row['image'] .'" '; echo '/>'; } And, of course, have the URL to the image in the db table `markers` for each record. Move/style the image within the createMarker() function to suit your needs. Add width/height and so on. Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345603 Share on other sites More sharing options...
usman07 Posted May 15, 2012 Author Share Posted May 15, 2012 I added the image codes in the javascript and php, but the markers have now disappeared? Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345608 Share on other sites More sharing options...
mrMarcus Posted May 15, 2012 Share Posted May 15, 2012 I added the image codes in the javascript and php, but the markers have now disappeared? Do you have images in the database table `markers`? You have added the column `image`? If so, post what an example image URL is that you have in the table. Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345613 Share on other sites More sharing options...
usman07 Posted May 15, 2012 Author Share Posted May 15, 2012 Yeah I have added 1 url for 1 entry and wanted to see if it works. Heres the image of the markers table: Heres the line of code in javascript: var html = "<img src='" + image + "'/><span class='mapinfo'>" + name + "</span> <br/><br/>" + address; And the PHP: // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '<marker '; echo 'name="' . parseToXML($row['name']) . '" '; echo 'address="' . parseToXML($row['address']) . '" '; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo 'type="' . $row['type'] . '" '; echo 'image="' . $row['image'] . '" '; echo '/>'; } Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345616 Share on other sites More sharing options...
mrMarcus Posted May 15, 2012 Share Posted May 15, 2012 Can you either post a link to the project page (if not on localhost; and if you are OK with that), or do a view-source in your browser and paste the code here. Quote Link to comment https://forums.phpfreaks.com/topic/262524-how-could-i-style-the-echo/#findComment-1345618 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.