2014-09-25 38 views
-4

我正在尝试构建一个关于足球队的网页。需要中频功能的一些帮助

于是,我把信息在一个SQL文件,然后在XAMPP数据库。问题是,当我把对球员和教练这样的信息:http://i.imgur.com/6EuYNPh.png他们出现在“存储”部分和“奖杯”过,这使它看起来像恼人:P http://i.imgur.com/tht9vTP.png

所以我需要一个像一个代码如果市场价值或位置或出生地点=空,然后隐藏这些值(我的意思是隐藏:市场价值,位置等)我知道我必须在函数文件中使用IF函数。我尝试了一些,但实际上并没有工作。

准确的代码是什么,我必须使用,我应该把它放在哪里?

功能的文件是在这里:

<?php 

//Position:  
//function to generate the local navigation bar for the bookstore web application 

function gen_navigation(){ 
include("dbconnect.php"); 
echo "<head>"; 
echo '<link rel="stylesheet" type="text/css" href="css/navigation.css" />'; 
echo "</head>"; 
$query="select * from categories"; 
$result=mysql_query($query); 
echo "<div id=navcontainer>"; 
echo "<ul id=navlist>"; 
while($row=mysql_fetch_array($result)){ 
echo "<li>"; 
echo "<a href=items.php?categoryid="; 
echo $row['categoryid']; 
echo ">"; 
echo $row['name']; 
echo "</a>"; 
echo "</li>"; 
} 
echo "</ul>"; 
echo "</div>"; 
mysql_close(); 

} 

//Position:  
//function to display the new items. The layout is formated by using tables 

//position:  
//function to display the new items. The layout is formated by using tables 
function showbooksbycat($categoryid=1,$offset=0,$limit=8){ 
if(empty($offset)){ 
    $offset=0; 
    } 
include("dbconnect.php"); 
$query="select * from items where categoryid=$categoryid order by isbn limit $offset,$limit"; 

$result=mysql_query($query); 

echo "<br>"; 
while($row=mysql_fetch_array($result)){ 
echo "<table width=100% border=0>"; 
echo "<tr class=newitems>"; 
echo "<th>"; 
    echo "Market Value".$row['market value']; 
    echo "</th>"; 
    echo "<th>"; 
     echo $row['name']; 
     echo "</th>"; 
echo "</tr>"; 
echo "<tr>"; 
     echo "<td width=100>"; 
    echo "<img src=pictures/".$row['picture'].">"; 
    echo "</td>"; 
     echo "<td align=left>"; 
    echo "<p class=itemmaininf>"; 
echo "<b>Name:</b> ".$row['name']."<br>"; 
echo "<b>Position:</b> ".$row['position']."<br>"; 
echo "<b>Place Of Birth:</b> ".$row['birthplace']."<br>"; 
    echo "<b>Date Of Birth:</b> ".$row['date']."<br>"; 

echo "<b>Previous Clubs:</b> ".$row['previous clubs']."<br>"; 
echo "</p>"; 
     echo "<p class=footitem>"; 
    echo "</p>"; 
    echo "</td>"; 
    echo "</tr>"; 
echo "</table>"; 
echo "<br>"; 
} 
mysql_close(); 
} 


function nav($categoryid=1,$offset=0,$limit=8){ 
include("dbconnect.php"); 
$query="select * from items where categoryid=$categoryid"; 
$result=mysql_query($query); 
$numrows=mysql_num_rows($result); 



echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; 

if($offset>0){ 

echo "<a href=items.php?categoryid=".$categoryid."&offset=".($offset-$limit); 
echo ">"; 
echo "<img border=0 src=pictures/prev.gif></a>"; 
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; 

} 

if($offset+$limit<$numrows){ 
echo "<a href=items.php?categoryid=".$categoryid."&offset=".($offset+$limit); 
echo ">"; 
echo "<img border=0 src=pictures/next.gif></a>"; 
} 
echo "</font>"; 
} 
?> 
+0

你不需要一个回波的每一行。 – 2014-09-25 21:21:40

+0

你试了一些东西,但实际上并没有工作。那可能是什么......?更好地了解你做错了什么,然后让别人给你答案... – 2014-09-25 21:22:09

+0

'所以我需要一个代码,如中频市场价值或位置或出生地点=空,'但没有像代码中的东西你发布了,所以这些代码与这个问题无关。 – developerwjk 2014-09-25 21:23:00

回答

1

的基本方法是

变化

echo "<b>Place Of Birth:</b> ".$row['birthplace']."<br>"; 

if(!empty($row['birthplace'])){ //! is not, so this says not empty 
    echo "<b>Place Of Birth:</b> ".$row['birthplace']."<br>"; 
} 
+0

OMG男人我爱你:d,它的工作,而现在它看起来过冷:d 十分感谢! 即时通讯对于描述中的代码抱歉,我把每个行cus的空间,它不让我上传它,但现在我修好了,希望它看起来更好,不要伤害你的眼睛和我的太:) 再次感谢您! :d – GamerX 2014-09-25 21:37:19