我有一个网站,它使用 lytebox 在当前网站的顶部显示一些图像和其他网站。这一切都很好,但我已经将数据传输到 MYSQL 数据库,现在该行的类不起作用。
这是我以前的东西,并且有效:
<div id="photo01">
<a href="images/strayKatts/photo01.JPG" title="" class="thickbox">
<img src="images/strayKatts/photo01.JPG" alt="Stray Katts Creations"
width="150px" height="113px" border="0"/>
</a>
</div>
但是因为我在目录中得到越来越多的数据,所以我将我的数据转移到一个 mysql 数据库中,以便于维护。
我可以提取数据和所有内容,可能只是没有显示,我目前有这个:
<div id="photo01">
<?php
$category_set = mysql_query("SELECT * FROM currentmarkets
WHERE id = '3' AND visible = '1';", $dbconnect);
if (!$category_set) {
die("Database query failed: " . mysql_error());
}
while ($titleItem = mysql_fetch_array($category_set)) {
echo "<a href='{$titleItem["imageLink01"]}' title='' class='thickbox'><img src='{$titleItem["imageSrc01"]}' alt='{$titleItem["imageAlt01"]}' width='150px' height='113px' border='0'/>";}
?></div>
我确信这与我使用 '' 和 ""的方式不正确有关。
还有什么建议/帮助吗?
编辑!!
抱歉,也许我做的不对,但我已经尝试了所有的答案,但没有一个能改变任何东西,即使它们看起来是正确的——这令人困惑:-)
哦,抱歉,我忘了 - 我再也不会这样做了:-)
最佳答案
像这样尝试,使用串联。还尝试只打印获取的数组,看看它是否是你在 php 中嵌入的 html 的问题,或者检查查询是否正常。
<div id="photo01">
<?php
$category_set = mysql_query("SELECT * FROM currentmarkets WHERE id = '3' AND visible = '1';", $dbconnect);
if (!$category_set) {
die("Database query failed: " . mysql_error());
}
while ($titleItem = mysql_fetch_array($category_set)) {
echo "<a href='".$titleItem["imageLink01"]."' title='' class='thickbox'><img src='".$titleItem["imageSrc01"]."' alt='".$titleItem["imageAlt01"]."' width='150px' height='113px' border='0'/>";}
?></div>
关于php - 从 mysql 数据库中提取数据时,如何在 php 字符串中使用多个属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9283774/