Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将数据库中的列表项相邻显示?_Php_Html_Mysql_Sql_Dom - Fatal编程技术网

Php 如何将数据库中的列表项相邻显示?

Php 如何将数据库中的列表项相邻显示?,php,html,mysql,sql,dom,Php,Html,Mysql,Sql,Dom,我有以下页面,其中显示了我的景点表中的景点列表: <!DOCTYPE HTML> <html> <body> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script src="jquery.imagemapster.js"></script> <l

我有以下页面,其中显示了我的景点表中的景点列表:

<!DOCTYPE HTML>
<html>
<body>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="jquery.imagemapster.js"></script>
<link rel="stylesheet" type="text/css" href="css.css" />



<title>VisitBulgaria</title>
</head>



<div class="banner">




<a href="home.html">
<img src="images/banner.png"   alt="kimtech" border="0" height="150" width="500" /></a>

<div class="namelog">


<?php 

if (isset($_SESSION['ID'])){


 echo $Forename." ".$LastName; 
 echo '<a href="logout.php">Logout</a> &sol; '; 
 echo '<a href="userpage.html">Account</a>'; 

}

 else {

 if (!isset($_SESSION['ID'])){


 echo '<a href="login.php">Log In</a> &sol; ';
 echo '<a href="register.php">Register</a>';

 }
}
?>
</div>




</div>

<div class="center">
<div class="menu">


<ul>
<li ><a href="home.html">Home</a></li>
<li class='active'><a href="attractions.html">Attractions</a>


<ul class="sub-menu">
            <li>
                <a href="historyv.html">Historical Villages</a>
            </li>
            <li>
                <a href="nature.html">Nature</a>
            </li>
            <li>
                <a href="sr.html">Seaside Resorts </a>
            </li>
            <li>
                <a href="wr.html">Winter Resorts </a>
            </li>
             <li>
                <a href="atimes.html">Ancient Times</a>
            </li>

        </ul>


</li>
<li><a href="traditions.html">Traditions</a></li>
<li><a href="pictures.html">Pictures</a></li>
<li><a href="about.html">About Us</a></li>






</ul>

</div>










<div class="center1">


<?php

if (!$link = mysql_connect('localhost', 'root', '')) {
    echo 'Could not connect to mysql';
    exit;
}

if (!mysql_select_db(')) {
    echo 'Could not select database';
    exit;
}

$sql    = "SELECT `AttractionID`,`Name`, `Location`, `Description`, `Airport`, `imglink`, `imglink2`   FROM `attractions` WHERE `Category`='HistV'";
$result = mysql_query($sql, $link);

if (!$result) {
    echo "DB Error, could not query the database\n";
    echo 'MySQL Error: ' . mysql_error();
    exit;
}




while ($row = mysql_fetch_assoc($result)) {

 echo "<a href='attraction.php?village=" . $row['AttractionID'] . "'>" .  "<br />" .
          $row['Name']  .
           "<br />" .

         "<img src='" . $row['imglink2'] . "' height='130' width='150'> 

       </a>";

}
mysql_free_result($result);

?>







</div>







</div>

 </body>
</html>
现在,我的数据库中的项目显示为一个列表,一个在另一个之下,如expact。 我怎样才能使它显示列表中的两个项目,并在它们旁边显示另两个项目,依此类推? 有什么CSS我可以用吗?
谢谢

为什么不使用css的第n个子属性将偶数列表作为目标来将奇数列表添加到css中

ul.submenu {

}
ul.submenu li {

    display: inline;
    height: 50px;

    margin: 20px;
    float: left;
}

ul.submenu li:nth-child(odd) {
    color: #F00;
    clear: left;
}

希望这能起作用我已经更新了fiddle here Customize to you usage

是的,你可以使用一个表。如果我使用一个表,我不能单击它们,我需要能够单击它们。好的,不要将href属性放在其自身中,但就在它之后:。它在语义上是不正确的,因为as-inline元素用作块级元素,但通常可以工作。您可以使用CSS:a{display:block;}将其设置为块元素