sildona Posted October 28, 2012 Share Posted October 28, 2012 I have echo "# blocks: "; echo stripslashes($imgrow[blocks]). "<br/>"; and the CSS is .blocks{ width:25px; color:#D82B2B; } How do I apply the CSS color to the Echo statement? I've looked at various tutorials, and it's not making sense. Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/ Share on other sites More sharing options...
Jessica Posted October 28, 2012 Share Posted October 28, 2012 Wrap it In a span, div, p etc with the class of blocks. Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388199 Share on other sites More sharing options...
Pikachu2000 Posted October 28, 2012 Share Posted October 28, 2012 Do you know how to use CSS without php? Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388200 Share on other sites More sharing options...
sildona Posted October 28, 2012 Author Share Posted October 28, 2012 Without PHP, yes. I just call the CSS file at the beginning of the page then modify the CSS file as necessary. Same thing? Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388203 Share on other sites More sharing options...
Pikachu2000 Posted October 28, 2012 Share Posted October 28, 2012 All you need to do is have php echo the values, along with the usual html markup, just as it would be normally. The stylesheet can be included just as you usually would. Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388204 Share on other sites More sharing options...
sildona Posted October 28, 2012 Author Share Posted October 28, 2012 I have the style sheet called in the PHP file's head. It's the wrapping in html markup that's throwing me. echo <style="color: $fff;" stripslashes($imgrow[blocks]). "<br/>"; echo stripslashes($imgrow[blocks])." <br/>"; echo "<div class='blocks'></div>"; Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388206 Share on other sites More sharing options...
Jessica Posted October 28, 2012 Share Posted October 28, 2012 Seriously? You know how you put the br after the stripslashes? Why didn't you do the same with the rest of the HTML? Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388207 Share on other sites More sharing options...
Pikachu2000 Posted October 28, 2012 Share Posted October 28, 2012 And that brings up another question. Why are you using stripslashes() at all? Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388208 Share on other sites More sharing options...
sildona Posted October 28, 2012 Author Share Posted October 28, 2012 I really don't get this -- why would want to include more line-break tags? Really, I can write HTML well enough, so that it works. I can work my way through CSS just fine, and when I can't, tutorials help. But I'm not understanding how to wrap PHP echo statements with HTML. I just need to change the color of a measly piece of text. Telling me the concept isn't going to work. An example might be nice. In carpentry, for example, telling someone how to frame a wall and showing someone is the difference between some true and a not-very true corners. I have tried about 18 different examples from tutorials placed online, and if I just flat out copy and past them in a new php file, they still tend not to work. It's like everyone has a library of different, non-working examples. For example: echo "<div class='cars'>" ($variable[cars]). "</div>"; doesn't work. Yet I'm told it should. But I'm telling you ... it ain't happenin'. Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /............ eval()’d code on line 68 Any help anyone? Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388210 Share on other sites More sharing options...
sildona Posted October 28, 2012 Author Share Posted October 28, 2012 I don't want to write perfect code. I want workable code. I don't know if the stripslashes are needed, but the "blocks" variable comes from a form that inputs some data that may or may not have comma's or other stuff in it, so I added the stripslashes. Is that wrong? If it is, I don't mind. They don't give me error messages. They do allow the text to echo as its entered. I don't need a better, more pure, more esoteric way of doing this. I just need the output to be a certain color, which means calling the CSS file, which I swear to God is not making sense to me. Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388211 Share on other sites More sharing options...
Pikachu2000 Posted October 28, 2012 Share Posted October 28, 2012 Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /............ eval()’d code on line 68 That makes me think you're definitely doing something wrong. Where is that coming from? Nobody that knows anything about php would tell you this should work: echo "<div class='cars'>" ($variable[cars]). "</div>";; it has syntax errors. Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388213 Share on other sites More sharing options...
sildona Posted October 28, 2012 Author Share Posted October 28, 2012 Of course I'm doing something wrong. This works. echo stripslashes($imgrow[blocks])." <br/>"; It's nice and gray, and the line breaks as needed. What I would really like is for the blocks variable to be red. Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388214 Share on other sites More sharing options...
Pikachu2000 Posted October 28, 2012 Share Posted October 28, 2012 Why are you using eval() for anything? That shouldn't be needed at all. How about posting enough of the code so you can get help doing it the right way? Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388215 Share on other sites More sharing options...
sildona Posted October 28, 2012 Author Share Posted October 28, 2012 http://stackoverflow.com/questions/8110309/php-print-css-style echo "<span class='blocks'> $imgrow[blocks]<span>"; Works. Thanks all for putting up with my questions. Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388216 Share on other sites More sharing options...
Pikachu2000 Posted October 28, 2012 Share Posted October 28, 2012 Great. Now you have code that is probably very insecure, but makes things show up in pretty colors. Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388236 Share on other sites More sharing options...
sildona Posted October 28, 2012 Author Share Posted October 28, 2012 First, Jessica and Picachu2000 I really want to thank you both for putting up with my questions. I mean that. My background is English, and I get annoyed with people who don't appreciate or don't really want to learn what I think is very important. However, as an educator, even when I'm annoyed, I provide specific answers to specific questions I find tedious. Students of English are not always at the same point in their writing careers, and if they don't care--if they only want the answer--making their lives difficult only makes them resent me as well as the subject matter. Making their lives easy ... a.k.a, improving their lives ... in a way that serves their function rather than mine, keeps them close to the subject and will enable them to re-approach the topic at some later time with a positive mindset. Although teaching coding is similar to teaching writing, it's more like teaching business writing. Students of business writing have specific goals .. how to write a pitch, how to draft a business plan, how to do a PR, etc. Their mindset is functional rather than conceptual, and although they understand the importance of grammar and syntax, neither are their primary concern. Why? Because they are business people who can have a colleague proof the letter. When it comes to coding, I'm similar to the business-writing student. I have specific goals. I don't really give a can of shit about the security of the code because I have to get a working model in place that will allow me to conduct a private beta-testing, something I can run by others. Following that, I will pay someone to make code the site and fill in all the gaps, so to speak. So again, I really thank everyone in these forums for putting up with questioners of a business mindset. You people really find us annoying. Sorry. That said, considering myself an idea man, this is my idea: Think of a forum as an a single entity. Forums are amusing, very schizo places. Going back over not only this thread but over others, the overall personality is a mercurial. Although they are comprised of many users, think of PHP Freaks as PHP Freak. Religious: arguing about the absolute best, most moral way to code something: Bitter: don't want to dole out a single example because coders are angry about "spoon-feeding. ADHD: getting sidetracked away from the topic. Passive-Helpful: conceptual answers without specific examples (this is very close to #2. Helpful: conceptual answers with examples Chatty, Friendly: between questioners and regular users Identify other characteristics, say 10 total. Problems (market or audience) Supposing the singularity will be a hive mind, how to predict the personality that will win out (and therefore the nature of existence) Entertainment - perhaps a game Think of some more markets or audiences Code the Solution Write program that mimics or uses the forum model as a metaphor In terms of Problem #1 -- think of earthquake prediction ... input a lot of variables -- output earthquake predictions & effects. Similar thing: input various personality or objective survival goals and output the Singularity hive mind's most probably "personality" or "nature of existence." Entertainment (or even functional) Think of Yahoo! Answers, and model a visual site that uses the forum as a model ... A sort of schizo virtual assistant ... these already exist, but do any of them have a personality of anything other than an encyclopedia that has undergone customer service 101 training? OR program a forum-based virtual assistant -- a sort of Schizo sage -- that seeks to identify the questioner and give an answer that bests suits the person rather than the question ... many people might find this maddening. But designed and marketed properly, it could be like some wise mentor of sorts that frames answers like a zen koan. Sort of like Harry Potter getting seemingly confusing answers from Dumbledore. I don't have the time, knowledge, or inclination to start the above project, but it could be interesting and profitable if done right. Best Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388239 Share on other sites More sharing options...
Pikachu2000 Posted October 28, 2012 Share Posted October 28, 2012 (edited) I have very specific goals, too. One of them is not to help someone do something the wrong way, whether it's what they desire or not. To knowingly do otherwise would be irresponsible, and only serve to reinforce the misguided perception that as long as something "works", it doesn't need to be done properly. There's rather a large difference between overlooking improper sentence structure and supplying or even endorsing bad code. The latter can potentially enable a morally challenged visitor to cause the complete undoing of countless hours of someone's work in mere seconds. Because most of us actually do care when something like that happens, if a person starts implying they don't care about the right way, the likelihood they'll be ignored increases dramatically. Edited October 28, 2012 by Pikachu2000 Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388243 Share on other sites More sharing options...
Jessica Posted October 28, 2012 Share Posted October 28, 2012 (edited) Especially when that person is a newbie coming in and trying to tell people who've been here for years that we're using our forum wrong. You get paid to put up with shitty annoying questions. We don't. We're going to do whatever the hell we want with our time, and for me, it's tell someone they're being a moron when they can do echo stripslashes($imgrow[blocks])." <br/>"; echo "<div class='blocks'></div>"; But it takes them a full day to figure out how to put the div around the function, and they still do it wrong. Are you seriously telling me that you have a professional career as an educator, and you can't extrapolate that if you can do echo stripslashes($imgrow[blocks])." <br/>"; You can do echo '<div class="blocks">'.stripslashes($imgrow[blocks])."</div>"; Furthermore, you need to turn on error reporting to E_ALL because your current code should produce some warnings. If your plan is to hire someone to finish the project, why not hire them now to do it right from the start? Anyone worth their salt will look at your existing code and scrap it anyway. Edited October 28, 2012 by Jessica Quote Link to comment https://forums.phpfreaks.com/topic/269989-use-css-to-modify-echo-color/#findComment-1388253 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.