duangai1368 2015-11-17 00:30
浏览 114
已采纳

将mysql数据放入html中存在的div中

I'm able to display mysql data from my database by simply echoing it in a blank div however I'd like to display it into an existing div style, by that I mean the style is already set.

I'm having trouble showing the right information in the write places and I could use abit of help with fixing up my code. Here is the code for the html div :

<div class="[ col-xs-12 col-sm-offset-2 col-sm-8 ]" style="margin-top: 10px">
                <ul class="event-list">
                    <li>
                        <time datetime="2014-08-22">
                            <span class="day">22</span>
                            <span class="month">AUG</span>
                            <span class="year">2014</span>
                            <span class="time">ALL DAY</span>
                        </time>
                        <img alt="Steakout" src="http://www.thedramateacher.com/wp-content/uploads/2014/04/vcaa-2014.jpg" />
                        <div class="info">
                            <h2 class="title">Night before VCAA</h2>
                            <p class="desc">Staying.</p>
                        </div>
                        <div class="social">
                            <ul>
                                <li class="facebook" style="width:33%;"><a href="#facebook"><span class="fa fa-facebook"></span></a></li>
                                <li class="twitter" style="width:34%;"><a href="#twitter"><span class="fa fa-twitter"></span></a></li>
                                <li class="google-plus" style="width:33%;"><a href="#google-plus"><span class="fa fa-google-plus"></span></a></li>
                            </ul>
                        </div>
                    </li>

In php I've decided to just recreate the whole div and just add the data I'd like to show into the div, it worked when I was just displaying unested divs but now that theres more it's gotten confusing.

Here is my Php code:

include('Specials.html');
$Category = 'Specials';
$query = $pdo->prepare("SELECT * FROM adsubm WHERE CATEGORY LIKE '%$Category%'");
$query->execute();

while($row = $query->fetch()) { 

  echo "<div class ='[ col-xs-12 col-sm-offset-2 col-sm-8 ] style='margin-top: 10px'>
        <ul class='event-list'>
           <div class='info'>
                   <div class='info'>
                     <h2 class='title'>".$row['ADTITLE'],
                        <time datetime>.$row['DATE'],

                         <p class='desc'> $row['DESCRIPTION']."</div></ul></div></div></h2></p>";


} 

?>

I've been doing it piece by piece and testing each time but this time there are errors just popping up everywhere. Kudos.

  • 写回答

2条回答 默认 最新

  • dsiy62758 2015-11-17 00:37
    关注
    while($row = $query->fetch()) { 
    
      echo "<div class ='[ col-xs-12 col-sm-offset-2 col-sm-8 ] style='margin-top: 10px'>
            <ul class='event-list'>
               <div class='info'>
                       <div class='info'>
                         <h2 class='title'>".$row['ADTITLE'].
                            "<time datetime>".$row['DATE'].
    
                             "<p class='desc'>". $row['DESCRIPTION']."</div></ul></div></div></h2></p>";
    
    
    } 
    

    some minor changes

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog