doucha7329 2015-01-01 21:42
浏览 94
已采纳

如何将echo插入div

I'm new here, so do not be angry if I ask something that is already answered.

I connected sql database: connect.php

<?php
$connect = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("mobilni", $connect) or die(mysql_error());
?>

displaydata.php

<?php  
include "connection.php";
$sql= "SELECT * FROM imena WHERE Okrug='Beogradski'";
$query=mysql_query($sql) or die (mysql_error());

?>
<div class="beyondheader"></div>
<div class="header">
    <div id='cssmenu'>
        <ul>
            <li class='active'><a href='index.html'>Početna</a></li>
            <li><a href='proizvodjaci.html'>Proizvodjači</a></li>
            <li><a href='oglasi.html'>Oglasi</a></li>
            <li><a href='about.html'>O nama</a></li>
        </ul>
    </div>
</div>

<div class="middle">
    <div class="leftmiddle">ss
    </div>
    <div class="rightmiddle">
        <?php 
            while ($row = mysql_fetch_array($query)){
        ?>
        <div class="divmobilni">
            Ime:<div class="mobilniime"><?php echo $row['Ime'];?></div>

            Okrug:<?php echo $row['Okrug'];?>
        </div>

        <?php } ?>
    </div>
</div>

And everything is working fine. Now I want to put every result in the other <div> automatically? How to do that?

Sorry if I wasn't clear enough. I want to sort results to be like this, in one <div> goes: Ime: Okrug: [that is data for one person]
Now, I want to make that all data from my SQL table display on this page, but every Person separately from this <div>.
To be something like this, with data from table: (This is just example drawn in Paint) example drawn in Paint

I fixed this with adding only break to the end of PHP. Thanks in any case!

  • 写回答

1条回答 默认 最新

  • dongzhunnai0140 2015-01-01 21:46
    关注

    Exactly the same as you would with php open and close <?php ?>

    Use this inside the divs you would like or just use echo with the div inside

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测