Try to do one html table
Posted: Thu Jan 21, 2010 3:39 am
Hi
I try to do one html table to show all the contents of my table. I have one or two problems. First when i write
print"<td>"."Preco_compra".print"</td>"; i'll get Preco_compra1 , why 1?
Second when i write print "<td>". print "<a href='http://mariolopes.com'>Editar</a>".print "</td>"; it changes the line and mispresent all table.
Here is the complete code:
<?php
//acesso à base de dados
$mysql_id = mysql_connect('localhost', "curso", "123");
mysql_select_db('mariolopes',$mysql_id);
$query="select * from negocios order by id DESC";
$result=mysql_query($query);
print"<table border='1'>";
print"<tr>";
print"<td>"."Editar"."</td>";
print"<td>"."Id".print"</td>";
print"<td>"."Código".print"</td>";
print"<td>"."Designação->".print"</td>";
print"<td>"."Preco_compra".print"</td>";
print"<td>"."Preco_venda".print"</td>";
print"</tr>";
while($row=mysql_fetch_array($result)){
print "<tr>";
print "<td>". print "<a href='http://mariolopes.com'>Editar</a>".print "</td>";
print "<td>". $row['Id'].print"</td>";
print "<td>". $row['Codigo'].print"</td>";
print "<td>". $row['Designacao'].print"</td>";
print "<td>". $row['Preco_compra'].print"</td>";
print "<td>". $row['Preco_venda'].print"</td>";
print"</tr>";
}
?>
I try to do one html table to show all the contents of my table. I have one or two problems. First when i write
print"<td>"."Preco_compra".print"</td>"; i'll get Preco_compra1 , why 1?
Second when i write print "<td>". print "<a href='http://mariolopes.com'>Editar</a>".print "</td>"; it changes the line and mispresent all table.
Here is the complete code:
<?php
//acesso à base de dados
$mysql_id = mysql_connect('localhost', "curso", "123");
mysql_select_db('mariolopes',$mysql_id);
$query="select * from negocios order by id DESC";
$result=mysql_query($query);
print"<table border='1'>";
print"<tr>";
print"<td>"."Editar"."</td>";
print"<td>"."Id".print"</td>";
print"<td>"."Código".print"</td>";
print"<td>"."Designação->".print"</td>";
print"<td>"."Preco_compra".print"</td>";
print"<td>"."Preco_venda".print"</td>";
print"</tr>";
while($row=mysql_fetch_array($result)){
print "<tr>";
print "<td>". print "<a href='http://mariolopes.com'>Editar</a>".print "</td>";
print "<td>". $row['Id'].print"</td>";
print "<td>". $row['Codigo'].print"</td>";
print "<td>". $row['Designacao'].print"</td>";
print "<td>". $row['Preco_compra'].print"</td>";
print "<td>". $row['Preco_venda'].print"</td>";
print"</tr>";
}
?>