我是一个全新的PHP新手,对我正在做的事情一无所知。通过浏览这个站点,我找到了在PHP中嵌入HTML的方法。
然而,我不能让它工作。我的代码是:
<?php do { ?>
<?php if ($row_rsMore['contentID'] = 35) : ?>
<li><a href="aboutus.php"><h4><?php echo $row_rsMore['contentTitle']; ?></h4></a></li>
<?php elseif ($row_rsMore['contentID'] = 37) : ?>
<li><a href="contactus.php"><h4><?php echo $row_rsMore['contentTitle']; ?></h4></a></li>
<?php elseif ($row_rsMore['contentID'] = 38) : ?>
<li><a href="otherlinks.php"><h4><?php echo $row_rsMore['contentTitle']; ?></h4></a></li>
<?php else : ?>
<li><a href="more.php?idVal=<?php echo $row_rsMore['contentID']; ?>"><h4><?php echo $row_rsMore['contentTitle']; ?></h4></a></li>
<?php endif ?>
<?php } while ($row_rsMore = mysql_fetch_assoc($rsMore)); ?>我试着用单引号,双引号,括号和这些主题的变体将数字(35,37和38)括起来。
实际情况是,每个语句的'contentTitle‘都正确显示,但每个href显示相同的链接(第一个'if’即'aboutus.php')。
我哪里搞错了?
发布于 2017-01-11 20:26:19
试一试
if ($row_rsMore['contentID'] == 35) :而不是单个=
将all single =更改为==
https://stackoverflow.com/questions/41590917
复制相似问题