jbond Posted January 17, 2010 Share Posted January 17, 2010 Hello everyone, I am trying to redirect the output of echo statements to a fixed place on the screen. For this I created a div element (called display) and inside the do loop I am echoing the output to the div. However, every line gets overwritten by the next one, rather then scrolling down the window. Is this at all possible? Below is the code that does the echoing to the div element function verzend_multi($nummers,$tekstsms) { $nummer=explode(";",$nummers); $lus=count($nummer); for ($loop=0;$loop<$lus;$loop++) { $gsmnummer = "32" . substr($nummer[$loop],1,3) . substr($nummer[$loop],4,6); if (strlen($gsmnummer) == 11) { echo "<div id=display>verzending naar " . $gsmnummer . "<br /></div>"; } else { echo "<div id=display><font color=red>FOUT: Verkeerd geformateerd gsmnummer !! : " . $gsmnummer . "<br /></font></div>"; } } } and this is the css that formats the display div <style type="text/css"> <!-- #display { border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; border-top-style: double; border-right-style: double; border-bottom-style: double; border-left-style: double; height: 100px; top: 350px; position: absolute; width: 650px; overflow: scroll; display: inline; } --> </style> Has anyone got an idea on how to solve this? Thanks very much Quote Link to comment https://forums.phpfreaks.com/topic/188769-writing-echo-statements-to-div-element/ Share on other sites More sharing options...
oni-kun Posted January 17, 2010 Share Posted January 17, 2010 You are outputting a new div every iteration of the loop, Maybe you should define the div before the loop, and end the div after. Quote Link to comment https://forums.phpfreaks.com/topic/188769-writing-echo-statements-to-div-element/#findComment-996552 Share on other sites More sharing options...
jbond Posted January 17, 2010 Author Share Posted January 17, 2010 do you mean something along these lines $nummer=explode(";",$nummers); $lus=count($nummer); <div id="display">; for ($loop=0;$loop<$lus;$loop++) { $gsmnummer = "32" . substr($nummer[$loop],1,3) . substr($nummer[$loop],4,6); if (strlen($gsmnummer) == 11) { echo "verzending naar " . $gsmnummer . "<br />"; } else { echo "<font color=red>FOUT: Verkeerd geformateerd gsmnummer !! : " . $gsmnummer . "<br /></font>"; } } </div>; because this generates a parse error ... Quote Link to comment https://forums.phpfreaks.com/topic/188769-writing-echo-statements-to-div-element/#findComment-996556 Share on other sites More sharing options...
oni-kun Posted January 17, 2010 Share Posted January 17, 2010 Your code has errors in it, displaying HTML out of echo's. $nummer = explode(";",$nummers); $lus = count($nummer); echo '<div id="display">'; for ($loop=0;$loop<$lus;$loop++) { $gsmnummer = "32" . substr($nummer[$loop],1,3) . substr($nummer[$loop],4,6); if (strlen($gsmnummer) == 11) { echo "verzending naar " . $gsmnummer . "<br />"; } else { echo "<font color=red>FOUT: Verkeerd geformateerd gsmnummer !! : " . $gsmnummer . "<br /></font>"; } } echo '</div>'; This should work, provided you were wanting it to be within a single div (and not overwritten) Quote Link to comment https://forums.phpfreaks.com/topic/188769-writing-echo-statements-to-div-element/#findComment-996558 Share on other sites More sharing options...
jbond Posted January 17, 2010 Author Share Posted January 17, 2010 must have gotten up too early this morning.. you are right.. this works like a charm.. thanks a million for the assistance Quote Link to comment https://forums.phpfreaks.com/topic/188769-writing-echo-statements-to-div-element/#findComment-996576 Share on other sites More sharing options...
oni-kun Posted January 17, 2010 Share Posted January 17, 2010 No problem. Quote Link to comment https://forums.phpfreaks.com/topic/188769-writing-echo-statements-to-div-element/#findComment-996577 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.