简体   繁体   English

在回显表中更改字体大小

[英]Change font-size in echo table

I want to modify the font size based on a echo table. 我想根据回显表修改字体大小。 Here you can see me code... 在这里您可以看到我的代码...

    echo "<table>";
    foreach($pdo -> query($abgÜbersicht) as $row){
        echo "<tr>";
        echo "<td>".$row['Spiel']."</td>";
        echo "</tr>";
    }
    echo "</table>";

I think I have to fill in something like 我想我必须填写类似

<font-size: "xy"> 

But I am not really sure how to write it correctly regarding to the correct quote signs. 但是我真的不确定如何针对正确的引号正确编写它。

You need to use the style HTML property. 您需要使用style HTML属性。

echo "<table>";
foreach($pdo -> query($abgÜbersicht) as $row){
    echo "<tr>";
    echo "<td style=\"font-size: xy;\">".$row['Spiel']."</td>";
    echo "</tr>";
}
echo "</table>";

You can do it in two ways inline style and with style tag or separate file. 您可以通过两种方式内联样式,样式标签或单独的文件来实现。 Lets first do it in the first way: 首先让我们以第一种方式进行操作:

echo "<table>";
    foreach($pdo -> query($abgÜbersicht) as $row){
        echo "<tr>";
        echo "**<font size='16px' color='magenta' family='monospace'>**<td>".$row['Spiel']."</td>**</font>**";
        echo "</tr>";
    }
    echo "</table>";

the second way is to put style tag and give class to td. 第二种方法是放置样式标签并将类分配给td。

      echo "<table>";
            foreach($pdo -> query($abgÜbersicht) as $row){
                echo "<tr>";
                echo "<td **class='edit'**>".$row['Spiel']."</td>";
                echo "</tr>";
            }
             ?>
            <style type='text/css'>
              .edit{ color:magenta; font-size:16px; /*and whatever you 
              want*/
               </style>

After this line how to write it correctly regarding to the correct quote signs. 在此行之后, how to write it correctly regarding to the correct quote signs. i would like to share something about quotes in php . 我想分享一些有关php中引号的信息。 it was prepared few month back but while i fail to post . 它是在几个月前准备的,但是我无法发表。 Most of new developer will not know where to use single quotes and double quotes and how it behave . 大多数新开发人员将不知道在何处使用single quotesdouble quotes以及其behave

1 : First of all you need to know the difference bewtween single quotes and double quotes and when it's used 1:首先,您需要了解单引号和双引号之间以及使用时的区别

Single quotes 单引号

2 : Inside the single quotes everything consider as string . 2:在单引号内,所有内容都视为字符串。

$message1 = '<div style="color:#ff0000"> Message 1 </div>';

2.1 : Above example you can use double quotes inside single quotes but you should not use single quotes inside single quotes . 2.1:上面的示例可以在单引号内使用双引号,但不应在单引号内使用单引号。 if you need to use you need to escape it properly using backward slash (\\) . 如果需要使用,则需要使用slash (\\)正确转义。 like this $message1 = '<div style=\\'color:#ff0000\\'> Message 1 </div>'; 像这样$message1 = '<div style=\\'color:#ff0000\\'> Message 1 </div>';

Double quotes 双引号

3 : Inside the double quotes we can use single quotes $message1 = "<div style='color:#ff0000'> Message 1 </div>; but should not use double quotes inside the double quotes .if you need you need to ecape it properly like this like this $message1 = "<div style=\\"color:#ff0000\\"> Message 1 </div>"; 3:在双引号内,我们可以使用单引号$message1 = "<div style='color:#ff0000'> Message 1 </div>;但不要在双引号内使用双引号。如果需要, $message1 = "<div style=\\"color:#ff0000\\"> Message 1 </div>";这样正确地$message1 = "<div style=\\"color:#ff0000\\"> Message 1 </div>";

4 : $message1 = '<div style="color:#ff0000">$error</div>'; 4: $message1 = '<div style="color:#ff0000">$error</div>';

4.1 : In above example $error will consider as string . 4.1:在上面的示例中,$ error将被视为string。 it will not echo the value of variable ,because it's inside the single quotes . 它不会回显变量的值,因为它在单引号内。

overcome : 克服:

you can concatenate like this 你可以像这样串联

$message1 = '<div style="color:#ff0000">'.$error.'</div>';

5 : $message1 = "<div style="color:#ff0000">$error</div>"; 5: $message1 = "<div style="color:#ff0000">$error</div>";

5.1 : In above example $error will consider as variable because it's inside the dobule quotes . 5.1:在上面的示例中,$ error将被视为变量,因为它位于双引号内。

6 : $message1 = "<div style="color:#ff0000">'$error'</div>"; 6: $message1 = "<div style="color:#ff0000">'$error'</div>";

6.1 : In above example $error consider as variable and also it give the value with enclosed by single quotes . 6.1:在上面的示例中,$ error被视为变量,并且给出了用单引号引起来的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM