使PHP输出大胆

时间:2013-12-23 10:46:05

标签: php html

我无法弄清楚如何使我的php输出变粗,我尝试了 但是当我尝试时我收到并出错。我试图搜索这个主题,但在我的情况下,似乎没有任何答案可以帮助我。

   while($row = mysql_fetch_array($oPlayerInfo))
{
Print "".$row['FirstName']." ".$row['LastName']."<br>";
Print "Position: ".$row['Position']."<br>";
Print "Height: ".$row['Height']."<br>";  
Print "Weight: ".$row['Weight']."<br>";
Print "Birthdate: ".$row['DOB']."<br>";
Print "CNGHL Team: ".$row['CNGHLRights']."<br>";
Print "NHL Team: ".$row['Team']."<br>";
Print "Draft Year: ".$row['CNDraftYR']."<br>";
Print "Draft Position: ".$row['CNDraftPOS']."<br>"; 
Print "Drafted By: ".$row['CNDraftTEAM']."<br>";
Print "<img src=\"http://www.cnghl.biz/cnghldb/images/".$iPlayerID.".jpg\">";

5 个答案:

答案 0 :(得分:7)

只需在您的打印中添加HTML强标记,然后删除不需要的行。

while($row = mysql_fetch_array($oPlayerInfo))
{
  Print "<strong>".$row['FirstName']." ".$row['LastName']."</strong><br>";
  Print "<strong>Position: ".$row['Position']."</strong><br>";
  Print "<strong>Height: ".$row['Height']."</strong><br>";  
  Print "<strong>Weight: ".$row['Weight']."</strong><br>";
  Print "<strong>Birthdate: ".$row['DOB']."</strong><br>";
  Print "<strong>CNGHL Team: ".$row['CNGHLRights']."</strong><br>";
  Print "<strong>NHL Team: ".$row['Team']."</strong><br>";
  Print "<strong>Draft Year: ".$row['CNDraftYR']."</strong><br>";
  Print "<strong>Draft Position: ".$row['CNDraftPOS']."</strong><br>"; 
  Print "<strong>Drafted By: ".$row['CNDraftTEAM']."</strong><br>";
  Print "<img src=\"http://www.cnghl.biz/cnghldb/images/".$iPlayerID.".jpg\">";
}

有了这个

Print "<strong>Height: ".$row['Height']."</strong><br>";

整条线都是大胆的。用下面的那个

Print "<strong>Height:</strong> ".$row['Height']."<br>";

只有标签才是粗体。

答案 1 :(得分:1)

试试这个......

<?php
while($row = mysql_fetch_array($oPlayerInfo))
{
    echo "<strong>"; // <---- Added here
    echo "".$row['FirstName']." ".$row['LastName']."<br>";
    echo "Position: ".$row['Position']."<br>";
    echo "Height: ".$row['Height']."<br>";
    echo "Weight: ".$row['Weight']."<br>";
    echo "Birthdate: ".$row['DOB']."<br>";
    echo "CNGHL Team: ".$row['CNGHLRights']."<br>";
    echo "NHL Team: ".$row['Team']."<br>";
    echo "Draft Year: ".$row['CNDraftYR']."<br>";
    echo "Draft Position: ".$row['CNDraftPOS']."<br>";
    echo "Drafted By: ".$row['CNDraftTEAM']."<br>";
    echo "</strong>"; // <-----Closing here
    echo "<img src=\"http://www.cnghl.biz/cnghldb/images/".$iPlayerID.".jpg\">";
}

答案 2 :(得分:1)

尝试使用firstname和lastname为粗体。

Print "<b>".$row['FirstName']." ".$row['LastName']."</b><br>"; //<b> and </b>

答案 3 :(得分:0)

您可以尝试将b或强标记添加到打印输出中:

    Print "<strong>Height: ".$row['Height']."</strong><br>"; 

或者@Shankar Damodaran发布的整个元素?

答案 4 :(得分:0)

好吧,我认为将这样的操作放在HTML文件中,这是一种不好的做法。我建议使用MVC模式。

像这样......

控制器

<?php
    $rows = array();

    while($row = mysql_fetch_array($oPlayerInfo))
       $rows[] = $row;

    return $rows;

?>

查看

<html>
    <head><title>Test</title></head>
    <body>
    <?php foreach($rows as $row): ?>
        <section>
            <div>
                <label>$row['FirstName']." ".$row['LastName']</label>
            </div>
            <div>
                <label>Position: ".$row['Position']</label>
            </div>
            <div>
                <label>"Height: ".$row['Height']</label>
            </div>
            <div>
                <label>Weight: ".$row['Weight']</label>
            </div>
            <div>
                <label>Birthdate: ".$row['DOB']</label>
            </div>
            <div>
                <label>CNGHL Team: ".$row['CNGHLRights']</label>
            </div>
            <div>
                <label>NHL Team: ".$row['Team']</label>
            </div>
            <div>
                <label>Draft Year: ".$row['CNDraftYR']</label>
            </div>
            <div>
                <label>Draft Position: ".$row['CNDraftPOS']</label>
            </div>
            <div>
                <label>Drafted By: ".$row['CNDraftTEAM']</label>
            </div>
            <div>
                <img src="http://www.cnghl.biz/cnghldb/images/".$iPlayerID.".jpg">
            </div>
        </section>
    <?php endforeach; ?>
    </body>
</html>