标题显示了我需要完成的工作,但随着页面的构建,我得到的是 3 列,每行的结果相同。每一行都是不同的,但每一行的每一列都重复相同的内容,而不是第一列、第二列和第三列的不同内容。
我在下面的代码中遗漏了一些东西来完成这项工作,任何帮助将不胜感激。
谢谢你。
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$results = mysql_query("SELECT title,link FROM syndicate ORDER BY popularity DESC LIMIT 75");
while ($row = mysql_fetch_array($results)){
$title = $row['title'];
$link = $row['link'];
if ($divtest = 1){
//insert in div col1;
echo '<div class="col1">';
///<!-- Column 1 start -->
echo '<a href="' . $link . '" target="_blank">' . $title . '</a><br><br>'; /// add all links here
///<!-- Column 1 end -->
echo '</div>';
$divtest = 2;
}
if ($divtest = 2){
//insert in div col2;
echo '<div class="col2">';
///<!-- Column 2 start -->
echo '<a href="' . $link . '" target="_blank">' . $title . '</a><br><br>'; /// add all links here
///<!-- Column 2 end -->
echo '</div>';
$divtest = 3;
}
if ($divtest = 3){
//else {
//insert in div col3;
echo '<div class="col3">';
///<!-- Column 3 start -->
echo '<a href="' . $link . '" target="_blank">' . $title . '</a><br><br>'; /// add all links here
///<!-- Column 3 end -->
echo '</div>';
$divtest = 1;
}
}