Jump to content

Writing echo statements to div element


jbond

Recommended Posts

:confused:

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/188769-writing-echo-statements-to-div-element/
Share on other sites

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 ...

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.