Jump to content

[SOLVED] Printing into a textarea


emilg

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.