Web Hosting Talk







View Full Version : PHP - Printing output to specific spot on html


JustinAY
06-22-2008, 04:48 PM
Hello!

I am wondering, how do you print output to specific spots on an HTML? I am trying to echo the variable I want printed in the spot I want on the page , however that doesn't appear to work. When I just echo it after using require() on the html page, it either goes to to the top or bottom.

Thanks for any help

111111z
06-22-2008, 05:01 PM
<?php
$i=2;


echo "<b>The value is $i</b>";


?>

try that

JustinAY
06-22-2008, 05:06 PM
Yes. I realize how to echo. However, echoing the variable in the block (in the <div> block of text) isn't working. However when I put this in the php file
$pingresult = shell_exec ("ping -c 3 $desiredhost");
echo ("<pre>$pingresult</pre>");

It just echos it at the very bottom.

111111z
06-22-2008, 05:22 PM
Sounds like you may have some output buffering on or something like that.

are you using ob_start somewhere in your code?

JustinAY
06-22-2008, 05:24 PM
No, I don't have ob_start anywhere. Should I?

111111z
06-22-2008, 05:35 PM
No ob_start not needed..........see link below

look at http://build1userver.com/pingtest.php

from this code - all in pingtest.php


<?php
$pr = shell_exec ("ping -c 3 yahoo.com");
?>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>New Page 1</TITLE>
</HEAD>

<BODY>

<DIV ALIGN="left">
<TABLE BORDER="0" WIDTH="411" HEIGHT="51">
<TR>
<TD WIDTH="185" HEIGHT="51">Pinging will now start</TD>
<TD WIDTH="216" HEIGHT="51">
<?php echo "<pre>$pr</pre>";?>
</TD>
<TD WIDTH="185" HEIGHT="51">Pinging will no stop</TD>
</TR>
</TABLE>
</DIV>