1

How can I add different font-styles to different rows?

I want all of them to have a different font-style. For example:

while($row = mysqli_fetch_array($result))
 {
  echo $row['Nimi']."<br>".$row['Kirjailija']."<br>".$row['ISBN']."<br>".$row['Kunto']."<br>".$row['Hinta']."€"."<br>".$row['Pvm'];
  echo "<br>"."<br>";
 }
0

3 Answers 3

1

I am not so good at php. But I gave a little try about it like this:

Slight modification to your code.. Adding a classing to each row!

i = 1;
while($row = mysqli_fetch_array($result))
 {
/* adding <span class="row1"> row2 etc.. using i */
  echo "<span class='row".i."'>".$row['Nimi']."<br>".$row['Kirjailija']."<br>".$row['ISBN']."<br>".$row['Kunto']."<br>".$row['Hinta']."€"."<br>".$row['Pvm'];
  echo "<br>"."<br></span>";
  i++;
 }

Giving Styles in css based on row names:

.row1{
 font-family: verdana;
}

.row2{
 font-family: arial;
}

etc..

I am repeating once again, I'm not sure about syntax.. I am posting this only to share the concept hoping that it should work! :)

Sign up to request clarification or add additional context in comments.

Comments

0

For example:

style="font-family:verdana;"

Comments

0

You can use inline styling <span style="color: red;">test</span>, or use classes of css: <span class="red-color">text</span> with a css

.red-color{
    color: red;
    font-family: Arial;
}

In general, it is better to use classes with an external css file - that would keep your code organized and scalable.

In your case it is possible to use inline style like:

echo "<span style=\"color: red; font-family: Arial\">" . $row['Nimi'] . "</span>" . "<span style=\"color: green; font-family: Verdana\">" . $row['Kirjailija'];

Also, it is not a good practice to use <br /> now-a-days. Better wrap each text with a <span>, or a <div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.