How to call two mysql tables on the same php page?

0

I'm new to web programming, and I'm having a hard time with that. I'm developing an advertisement site and need to call more than one table on the page.

I made 3 Div's of advertising: Main, Free and general.

I can only display the main, free and general ads I can not.

As I'm calling the major:

<?php
while ($dados=mysql_fetch_array($res))
{
?>

<?php echo $dados['site']?> <br>
<?php echo $dados['descricao']?> <br>
<img src="Painel/fotos/<?php echo $dados['foto']?> /><br>

<?php }?>

I try to do the same for the other two Div's and I can not, can you help me?

    
asked by anonymous 14.01.2015 / 18:58

1 answer

1

Just copy this code to the other divs, with a mysql_query and a mysql_fetch_array for each one. With mysql_query you got the data for this right? so .. get the data for each table in the other divs

Edit:

that is:

<?php 
    include ("conexao.php"); 

    $sql="select * from principal"; $res= mysql_query ($sql); 
    while ($dados=mysql_fetch_array($res))
    {
        echo $dados['site'] . "<br>";
        echo $dados['descricao'] . "<br>";
?>
<img src="Painel/fotos/<?php echo $dados['foto']?> /><br>

<?php } ?>
    <br><br>
<?php 
    $sql="select * from gratuitas"; $res= mysql_query ($sql);
    while ($dados=mysql_fetch_array($res))
    {
        echo $dados['site'] . "<br>";
        echo $dados['descricao'] . "<br>";
        ?>
    <img src="Painel/fotos/<?php echo $dados['foto']?> /><br>

<?php } ?>
    <br><br>
<?php 

    $sql="select * from geral"; $res= mysql_query ($sql); 
    while ($dados=mysql_fetch_array($res))
    {
        echo $dados['site'] . "<br>";
        echo $dados['descricao'] . "<br>";
    ?>
    <img src="Painel/fotos/<?php echo $dados['foto']?> /><br>

<?php }
?>

I have not tested this code, it may have some syntax error. Correct if any. The above code is to give you an idea of what I mean.

    
14.01.2015 / 19:05