duanbi3786 2015-11-19 13:58
浏览 26

如何从数据库中获取数据以使用PHP / jQuery进行呈现

Background: At the moment I have a static timeline html/css/jQuery. I want to take it a step further so I made a separate admin page that allows a user to enter the informatiom they want and a picture to appear on the timeline on the correct date (which is saved as date in the database)

I do not know how I can get the timeline to generate so that it displays entries from the database rather that the static timeline loader in the html page. So in other words it pulls the heading, the description the date and the image that was uploaded.

My thinking was using a foreach loop to echo the variables inside the tags that are already there. Such as this:

<div class="item" data-id="12/05/2012" data-description="Lorem ipsum dolor sit">
            <a class="image_rollover_bottom con_borderImage" data-description="ZOOM IN" href="images/flat/default/2.jpg" rel="lightbox[timeline]">
            <img src="$image" alt=""/>
            </a>
            <h2>'$date'</h2>
            <span><?php echo '$about' ?> </span>
            <div class="read_more" data-id="12/05/2012">Read more</div>

Sorry this is probably wrong, I'm not sure how to implement it in php.

Load Function:

$(window).load(function() {
    // light
    $('.tl1').timeline({
        openTriggerClass : '.read_more',
        startItem : '15/08/2014',
        closeText : 'x',
        ajaxFailMessage: 'This ajax fail is made on purpose. You can add your own message here, just remember to escape single quotes if you\'re using them.'
    });
    $('.tl1').on('ajaxLoaded.timeline', function(e){
        var height = e.element.height()-60-e.element.find('h2').height();
        e.element.find('.timeline_open_content span').css('max-height', height).mCustomScrollbar({
            autoHideScrollbar:true,
            theme:"light-thin"
        }); 
    });

});

Page that loads Timeline:

<div class="timelineLoader">
    <img src="images/timeline/loadingAnimation.gif" />
</div>
<!-- BEGIN TIMELINE -->
<div class="timelineFlat tl1">
        <div class="item" data-id="04/05/2014" data-description="Lorem ipsum">
            <a class="image_rollover_bottom con_borderImage" data-description="ZOOM IN" href="images/flat/default/1.jpg" rel="lightbox[timeline]">
            <img src="images/videoConferencingnodevices.jpg" width="410" height"275" alt=""/>  



            </a>
            <h2>MAY, 4</h2>
            <span>Example</br>
                Example  
        </span>
            <div class="read_more" data-id="04/05/2014">Read more</div>
        </div>
        <div class="item_open" data-id="04/05/2014" data-access="ajax-content-no-image.html">
            <div class="item_open_content">
                <img class="ajaxloader" src="images/timeline/loadingAnimation.gif" alt="" />
            </div>
        </div>

        <div class="item" data-id="12/05/2012" data-description="Lorem ipsum dolor sit">
            <a class="image_rollover_bottom con_borderImage" data-description="ZOOM IN" href="images/flat/default/2.jpg" rel="lightbox[timeline]">
            <img src="images/collabcompliant.jpg" alt=""/>
            </a>
            <h2>MAY, 12</h2>
            <span>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exerc...</span>
            <div class="read_more" data-id="12/05/2012">Read more</div>
        </div>
        <div class="item_open" data-id="12/05/2012" data-access="ajax-content-no-image.html">
            <div class="item_open_content">
                <img class="ajaxloader" src="images/timeline/loadingAnimation.gif" alt="" />
            </div>
        </div>  

Can anyone help me with how I can achieve this outcome and get the data to generate from the database?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab中使用gurobi时报错
    • ¥15 WPF 大屏看板表格背景图片设置
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂