dynamic table in html
Moderator: General Moderators
dynamic table in html
Hy all, im printing to the screen the results of a search i make. This is the script im using...
------------------------------------------------------------------------------------------------------------------------------------------
<?php if(isset($_POST['submit'])){
$id_medico = strip_tags($_POST['id_medico']);
$exc = "SHOW TABLES"; /*VARIÁVEL RENOMEADA*/
$query = mysql_query("SELECT * FROM mensagens WHERE id_medico = '".mysql_real_escape_string($id_medico)."'");
echo "<center><font face=Verdana size=2><b>Tabelas da base de dados</b></font></center><br>";
echo "<table>";
while($dados = mysql_fetch_array($query)){
$descreva = mysql_query("SELECT * FROM mensagens WHERE id_mensagem='". $dados[0] ."'");
while($atributos = mysql_fetch_array($descreva)){
echo "<tr><td><font face=Verdana size=1>$atributos[0]</td><td><font face=Verdana size=1>| $atributos[1]</td><td><font face=Verdana size=1>| $atributos[2]</td><td><font face=Verdana size=1>| $atributos[3]</td><td><font face=Verdana size=1>| $atributos[4]</td></tr>";}
echo "</table>";
}}else{$nome = '';}
?>
----------------------------------------------------------------------------------------------------------------------------------------------
The problem is that this way is not pleasant, and im here hoping u could help me making a table in html or something like that.
------------------------------------------------------------------------------------------------------------------------------------------
<?php if(isset($_POST['submit'])){
$id_medico = strip_tags($_POST['id_medico']);
$exc = "SHOW TABLES"; /*VARIÁVEL RENOMEADA*/
$query = mysql_query("SELECT * FROM mensagens WHERE id_medico = '".mysql_real_escape_string($id_medico)."'");
echo "<center><font face=Verdana size=2><b>Tabelas da base de dados</b></font></center><br>";
echo "<table>";
while($dados = mysql_fetch_array($query)){
$descreva = mysql_query("SELECT * FROM mensagens WHERE id_mensagem='". $dados[0] ."'");
while($atributos = mysql_fetch_array($descreva)){
echo "<tr><td><font face=Verdana size=1>$atributos[0]</td><td><font face=Verdana size=1>| $atributos[1]</td><td><font face=Verdana size=1>| $atributos[2]</td><td><font face=Verdana size=1>| $atributos[3]</td><td><font face=Verdana size=1>| $atributos[4]</td></tr>";}
echo "</table>";
}}else{$nome = '';}
?>
----------------------------------------------------------------------------------------------------------------------------------------------
The problem is that this way is not pleasant, and im here hoping u could help me making a table in html or something like that.
Re: dynamic table in html
Code: Select all
<?php
if(isset($_POST['submit']))
{
$id_medico = strip_tags($_POST['id_medico']);
$exc = "SHOW TABLES"; /*VARIÁVEL RENOMEADA*/
$query = mysql_query("SELECT * FROM mensagens WHERE id_medico = '".mysql_real_escape_string($id_medico)."'");
?>
<div id="topic">
<b>Tabelas da base de dados</b>
</div>
<table id="content">
<?php
while($dados = mysql_fetch_array($query))
{
$descreva = mysql_query("SELECT * FROM mensagens WHERE id_mensagem='". $dados[0] ."'");
while($atributos = mysql_fetch_array($descreva)) :
?>
<tr>
<td><?php echo $atributos[0]; ?></td>
<td>| <?php echo $atributos[1]; ?></td>
<td>| <?php echo $atributos[2]; ?></td>
<td>| <?php echo $atributos[3]; ?></td>
<td>| <?php echo $atributos[4]; ?></td>
</tr>
<?php endwhile; ?>
</table>
<?php
}
} else $nome = '';
?>What you need to do next if you want to use it is to create a stylesheet for it and include it on that page.
http://www.w3schools.com/Css/default.asp
Re: dynamic table in html
ur code give a error in the last line :/
Re: dynamic table in html
can you post the error it gave?
Re: dynamic table in html
try this?
Code: Select all
<?php
if(isset($_POST['submit']))
{
$id_medico = strip_tags($_POST['id_medico']);
$exc = "SHOW TABLES"; /*VARIÁVEL RENOMEADA*/
$query = mysql_query("SELECT * FROM mensagens WHERE id_medico = '".mysql_real_escape_string($id_medico)."'");
?>
<div id="topic">
<b>Tabelas da base de dados</b>
</div>
<table id="content">
<?php
while($dados = mysql_fetch_array($query))
{
$descreva = mysql_query("SELECT * FROM mensagens WHERE id_mensagem='". $dados[0] ."'");
while($atributos = mysql_fetch_array($descreva)) {
?>
<tr>
<td><?php echo $atributos[0]; ?></td>
<td>| <?php echo $atributos[1]; ?></td>
<td>| <?php echo $atributos[2]; ?></td>
<td>| <?php echo $atributos[3]; ?></td>
<td>| <?php echo $atributos[4]; ?></td>
</tr>
<?php endwhile; ?>
</table>
<?php
}
} else {$nome = '';}
?>
Last edited by mupparion on Tue Nov 24, 2009 9:50 am, edited 2 times in total.
Re: dynamic table in html
hmmm... not now :/ ... but that was not the topic of my post.... i would just wana know how can i create a dynamic table usign php/html... dont realy know how im going to do this...
Re: dynamic table in html
If you don't want to post the error we can't help you.
Regarding your question, use CSS as I said in my original post.
Regarding your question, use CSS as I said in my original post.
Re: dynamic table in html
dont knwo way but i paste ur code again "papa", and it works :/... thx man
Im going to try making a table now...
Im going to try making a table now...
Re: dynamic table in html
almost there ^^....
im doing like this--->
But only first field is being puted in the table :/... u know way??
im doing like this--->
Code: Select all
<table id="content" border="2" bordercolor="#00CC00">
<?php
while($dados = mysql_fetch_array($query))
{
$descreva = mysql_query("SELECT * FROM mensagens WHERE id_mensagem='". $dados[0] ."'");
while($atributos = mysql_fetch_array($descreva)) :
?>
<tr>
<td> <?php echo $atributos[0]; ?></td>
<td>| <?php echo $atributos[1]; ?></td>
<td>| <?php echo $atributos[2]; ?></td>
<td>| <?php echo $atributos[3]; ?></td>
<td>| <?php echo $atributos[4]; ?></td>
</tr>
<?php endwhile; ?>
</table>
<?php
}
} else $nome = '';
?>