简体   繁体   English

为什么不动态生成 <div> 显示?

[英]Why won't this dynamically-generated <div> display?

Okay, so on my website I have a slider thingy, where it um "slides" between things, and on the homepage, when the page loads it checks the database to see if Column discounts has a value of 1 (or greater than 0, to be precise), which means that if($discounts>0){//do something;} so, if the value inside the discount column is greater than 0, it will (SHOULD) display a dynamically created DIV saying something like "Yay we have discounts" etc. 好的,在我的网站上,我有一个滑块thing,它在各个事物之间“滑动”,在主页上,当页面加载时,它检查数据库以查看“列折扣”的值是否为1(或大于0,确切地说),这意味着if($ discounts> 0){//做某事;}因此,如果Discount列中的值大于0,它将(应该)显示动态创建的DIV,并显示“是的,我们有折扣”等

But, it won't display! 但是,它不会显示! It only displays 2 slides. 它仅显示2张幻灯片。 But the value in the DB is set to 1, so it should be displaying the 3rd slide! 但是数据库中的值设置为1,因此它应该显示第3张幻灯片!

Inside the Head: 头部内部:

if($ddiscount >0)
{           
    $outputsy = '<div class="ambitios_slide">

                     <div class="clear"> 

                         <h1 class="ambitios_fleft">'.$dimage.'</h1>

                         <div class="ambitios_sleder_title">'.$dtitle.'</div>

                         <p>'.$ddescription.'</p>

                     </div>

                  </div>';
 }
 else
 {
     $outputsy = null;
 }

Inside the body: 体内:

<?php if($outputsy != null) {echo $outputsy;} ?>

There are no warnings, no errors. 没有警告,没有错误。 The webpage loads fine. 网页加载正常。 It just never displays the dynamically generated DIV! 它永远不会显示动态生成的DIV! Can someone please help me figure out what is wrong here? 有人可以帮我弄清楚这里出什么问题了吗?

Any help is appreciated 任何帮助表示赞赏

Thank you 谢谢

in the else part, try setting $outputsy to some random string and see if that gets outputted. else部分,尝试将$outputsy设置$outputsy一些随机字符串,然后查看是否将其输出。

Also try doing a var_dump($ddiscount); 也尝试做一个var_dump($ddiscount); and seeing what the actual value of $ddiscount is. 并查看$ddiscount的实际值是$ddiscount If it's something other than what is expected, the problem may be something before this code. 如果不是预期的问题,则问题可能出在此代码之前。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM