$ block未被退回。在while语句中似乎出现了这个问题。我之前使用过这个脚本,只是略有不同,所以我知道这是一个相当小的东西。任何帮助将不胜感激,提前感谢。
<?php
if (isset($_GET['filter_tag'])) {
$filter_tag = $_GET['filter_tag'];
}
if (@mysql_connect('xxxxxxxxx','xxxxxxxxxx','xxxxxxxxxx')) {
if (mysql_select_db('xxxxx')) {
$query = " SELECT blocks . CNO, blocks . CName, blocks . URL, images . Ipath FROM blocks LEFT JOIN images ON blocks . INO = images . INO WHERE CNO LIKE 'mysql_real_escape_string($filter_tag)' ";
$query_run = mysql_query($query);
} while ($query_row = mysql_fetch_assoc($query_run)) {
echo $block = '<li id="'.$query_row['CNO'].'" class="block" data-toggle="modal" data-target="#blocklModal" >
<a href="'.$query_row['URL'].'" target="_blank">
<img class="b" src="'.$query_row["Ipath"].'" alt="" data-controls-modal="block-modal" data-backdrop="static">
</a>
<p class="c-title">'.$query_row['Name'].'</p>
</li>';
}
}
?>
答案 0 :(得分:0)
这可能有效(只要您的查询正确)。只要知道mysql_ *正在贬值,你应该真正使用PDO或MySQLi来运行你的查询。这个答案在不久的将来将毫无用处:
if (isset($_GET['filter_tag'])) {
$filter_tag = $_GET['filter_tag'];
if (mysql_connect('xxxxxxxxx','xxxxxxxxxx','xxxxxxxxxx')) {
if (mysql_select_db('xxxxx')) {
$filter_tag = mysql_real_escape_string($filter_tag);
$query = " SELECT blocks . CNO, blocks . CName, blocks . URL, images . Ipath FROM blocks LEFT JOIN images ON blocks . INO = images . INO WHERE CNO LIKE '$filter_tag'";
$query_run = mysql_query($query);
while ($query_row = mysql_fetch_assoc($query_run)) {
$block = '<li id="' . $query_row['CNO'] . '" class="block" data-toggle="modal" data-target="#blocklModal">';
$block .= '<a href="' . $query_row['URL'] . '" target="_blank">';
$block .= '<img class="b" src="' . $query_row["Ipath"] . '" alt="" data-controls-modal="block-modal" data-backdrop="static">';
$block .= '</a><p class="c-title">' . $query_row['Name'] . '</p></li>';
echo $block;
}
}
}
} else {
echo 'No filter tag provided';
}
尝试查看此链接以了解有关PDO / MySQLi的更多信息:PDO vs MySQLi - Which Should You Use