I want to have a small text box with a scroll bar that will hold frequent outputs from PHP based on server-side activity. How do I set up formatting like this?
-
By frequent outputs do you mean a lot of output, like debugging output? – Justin Poliey Jul 08 '09 at 18:11
-
It is debugging output, but its not a huge amount – blueintegral Jul 08 '09 at 18:27
4 Answers
The box:
<iframe style="overflow:auto; width:100px" src="status.php"/>
And in status.php you parse a log file, as explained here
How can I parse Apache's error log in PHP?
And you log interesting events/errors/warnings/debug in the log file.

- 1
- 1

- 4,670
- 3
- 24
- 24
I would either use a <pre>
or multiple <div>
s (one per line) instead of an input element. That way, you don't have to deal with making the input element read-only. If you use <div>
s, then you can also add classes to each line to style messages of different severity differently (for example, errors are red, warnings are orange etc.)

- 137,716
- 26
- 137
- 190
-
1And then add overflow: auto CSS if you really need those scroll bars ;) – Justin Poliey Jul 08 '09 at 18:12
You can simply echo out a text box or input box and make the value a variable which you can set however you like:
Textbox
echo '<textarea>' . $value . '</textarea>';
Input
echo '<input type="text" value="' . $value . '" />';
You can make these read only, and adjust the other HTML attributes as you like. Hope this helps.

- 14,183
- 17
- 67
- 103
-
1The textbox should be textarea and the value goes in between the opening and closing tag. – Sam Becker Jul 08 '09 at 18:00
Maybe what you really want is something like Gmail or Facebook chat (sort of push messages into the browser).
If that's what you're looking for go after the keyword 'Comet' otherwise you can just use an AJAX repeater to query the page every 'x' seconds and fetch new messages.

- 24,627
- 10
- 79
- 121