Page 1 of 1

Choose place where write text

Posted: Fri Feb 26, 2010 7:14 pm
by mariolopes
HI
I need to select one item from one database and write the result field in one place of my webpage, but when I write with echo"xxxx" it writes the value at the begining of the page. How can i choose the place where i write the result? I have to use css?
Thank you

Re: Choose place where write text

Posted: Fri Feb 26, 2010 10:31 pm
by s.dot
Hi,

Please show us your code. echoing something should place it right where you put the echo. I've seen cases where it doesn't, such as in templating.. so your code will be necessary.

Re: Choose place where write text

Posted: Sat Feb 27, 2010 12:08 pm
by mariolopes
HI
Here is my code:
One of my options was try to write the value in one input named designacao but it seems doesn't work.

Code: Select all

 
<?php
session_start();
include "tab.html";
echo"<link href='negocios.css' rel='stylesheet' type='text/css'>\n";
echo"<div class=formulario>";
echo"<form  method='POST' >";
echo"  <fieldset>";
echo"    <legend>Pesquisa:</legend>";
echo"    Código:        <input type='text' name='codigo' size='10' />";
echo"    <input type='Submit' value='Pesquisar'/>";
echo"<br/>";
echo"<br/>";
echo"Designação: <input type='text' name='designacao' size='50' value='";echo $descricao;echo "' />";
echo"  </fieldset>";
echo"</form>";
echo"</div>";
$mysql_id = mysql_connect('localhost', "xxx", "xxx");
mysql_select_db('mariolopes',$mysql_id);
if (isset($_POST['codigo'])){
        $query="select * from negocios where Codigo='$_POST[codigo]'";
        $result=mysql_query($query);
        $numlinhas=mysql_num_rows($result);
        echo $numlinhas;
if ($numlinhas==0){
$_SESSION['descricao']="";  
echo "Sem linhas";
exit;
}
while ($row=mysql_fetch_array($result)){
        $descricao=$row['Designacao'];      
        echo $descricao;        
}
}   
?>

Re: Choose place where write text

Posted: Sat Feb 27, 2010 12:13 pm
by lshaw
You only have echo statments at the top of the page, so where do you think they will appear?