emilg Posted June 30, 2009 Share Posted June 30, 2009 Hello everyone! I'm quite new to php, so forgive me if this is really simple, but I just can't figure it out. I have two functions that print a certain row with some variables. What I want to do is to print these lines(from both functions) into a single textarea , which will be hidden unless a user selects to view it. I understand hiding the textarea shouldn't be too hard, but I have no idea of how can I print into that textarea from both functions. Any help would be greatly appreciated! Quote Link to comment Share on other sites More sharing options...
aggrav8d Posted June 30, 2009 Share Posted June 30, 2009 please show us some code so we have a better understanding of what you mean. Quote Link to comment Share on other sites More sharing options...
emilg Posted June 30, 2009 Author Share Posted June 30, 2009 Thanks for your fast reply. One of my functions does the following: function mobHit() { global $char_info; global $mon_stats; global $user_check; global $mon_dmg; $query = "call monHit('$mon_dmg', '$user_check')"; $result = mysql_query($query); $char_info['health'] = $char_info['health'] - $mon_dmg; ?><font color="red"><? print ($mon_stats['name']. " hits you for ".$mon_dmg."<br>"); } The second function does something similar and has the same print line. Both functions are ran from a while loop. As it works now, they just print the line into the page. What I want to do is to print everything into a textarea instead, so I can hide and show it whenever I want to. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 30, 2009 Share Posted June 30, 2009 In general, functions should return the results produced by the function, rather than printing the results inside of the function. Once you do this, your function can be used in any situation. You could for example assign or concatenate the results returned by the function into a variable that you then print in a textarea. Quote Link to comment 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.