Place SELECT Mysql Items Side by Side with Bootstrap

Asked

Viewed 944 times

1

Good afternoon,

I am making a consultation in a bank, for a real estate site. I would like this query to generate the properties side by side, and not one below the other.

Is there a way to do this using Bootstrap? If not, how can I do it using tables?

Follow an example of the code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
    <title>teste</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <link rel="stylesheet" href="css/bootstrap.css">
</head>
<body>


    <div class="container-fluid">
        <div class="row">

        <?php
            require 'conexao.php';

            $sql = mysql_query("SELECT * FROM imoveisvenda");
            while($exibe = mysql_fetch_assoc($sql)){
        ?>

            <!-- VENDA -->
            <div class="col-md-3"> <br>
                    <img src="<?php echo "$exibe[v_imagem]";?>" class="img-responsive" alt="Casa para Venda">
                    <center><p style="margin-top:5%; font-size:20px; font-weight:bold; color:#001364; padding:2%;"><?php echo "$exibe[v_imovel]";?></p>
                    <p><?php echo "$exibe[v_localizacao]";?></p>
                    <p><?php echo "$exibe[v_detalhes]";?></p>
                    <p style="font-size:20px; font-weight:bold; color:#001364; padding:2%"><?php echo "$exibe[v_valor]";?></p></center>
            </div>
            <!-- VENDA -->

        </div>
    </div>

    <?php } ?>

    <script src="js/bootstrap.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

</body>

I need to enter some more information?

I appreciate the help!

Print do Problema

  • With past information it is difficult to help, add to the question the page on which you are trying to make this change.

  • What do you already have? Even if you are not the way you would like, show us what you have so we can help you.

  • @Vaati, I put the code I’m using, thank you for the alert

  • 1

    the way you, with col-Md-3, the data will already be side-by-side. Unless the screen resolution is small (on a mobile phone, for example).

  • @Fernandomondo Well placed! Now just see what he’s up to with the class .boxhome Hehee also has the question of whether the image is inside the div or if there is overflow, what would hinder.

  • @Fernandomondo, I took all classes, to see if there were any hindering the process. Let’s say I "almost" got there. There is still one item on top and the others below, not side by side. I would like to send a print, I’m trying to figure out how... rs...

Show 1 more comment

1 answer

1


Guys, thanks for the support!

I resolved that question as follows:

<div>

        <?php
            require 'conexao.php';

            $sql = mysql_query("SELECT * FROM imoveisvenda");
            while($exibe = mysql_fetch_assoc($sql)){
        ?>

            <!-- VENDA -->
            <div class="col-md-3"> <br>
                    <img src="<?php echo "$exibe[v_imagem]";?>" class="img-responsive" alt="Casa para Venda">
                    <center><p style="margin-top:5%; font-size:20px; font-weight:bold; color:#001364; padding:2%;"><?php echo "$exibe[v_imovel]";?></p>
                    <p><?php echo "$exibe[v_localizacao]";?></p>
                    <p><?php echo "$exibe[v_detalhes]";?></p>
                    <p style="font-size:20px; font-weight:bold; color:#001364; padding:2%"><?php echo "$exibe[v_valor]";?></p></center>
            </div>
            <!-- VENDA -->

        <?php } ?>

    </div>

I simply removed the "container" and "Row" class from the bootstrap, left only the col-Md-3 class, and to my surprise, stood side by side, straight.

Once again, thank you all!

  • Even if it worked, this is not the "right" way to use bootstrap. According to the documentation you should always have a container and Rows to group your cols.

  • I understand. But I have not found another way, unfortunately. I will still study more calmly, if I find another solution, put here. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.