How to add in <style> CSS php echo
Discuss coding issues, and scripts related to PHP and MySQL.
-
JanMolendijk
- Posts:282
- Location:Holland Rotterdam
How to add in <style> CSS php echo
Dear Coursesweb, Hope you do all fine
I can not find out how to add in the <style> a result from my database.
Hope to get some support for this. `thanks`
Code: Select all
<?php
include('../connection1.php');
$id = (int) $_GET['id'];
$sql=mysqli_query($connmaker,"SELECT * FROM `maker` WHERE post_id='" . $id . "' ");
$users=mysqli_fetch_assoc($sql);
?>
<style>
body {
font-family: "Exo 2", sans-serif;
display: flex;
justify-content: center;
align-items: center;
background: <?php echo $users['bbgcolor'];?>;
min-height: 100vh;
}
</style>
MarPlo
Posts:186
Hello,
Try the followig code:
Code: Select all
<?php
include('../connection1.php');
$bgc_user ='green'; // default color
if(isset($_GET['id'])) $id = (int) $_GET['id'];
else $id =1;
$result= mysqli_query($connmaker, "SELECT * FROM maker WHERE post_id=". $id);
while($row = mysqli_fetch_assoc($result)){
$bgc_user = $row['bbgcolor'];
}
?>
<style>
body {
font-family: "Exo 2", sans-serif;
display: flex;
justify-content: center;
align-items: center;
background: <?php echo $bgc_user; ?>;
min-height: 100vh;
}
</style>
- If the color is in hex code, add # before it (ex.:
background: #aabcfe;).
JanMolendijk
Posts:282
O GOD THANKS MARPLO
When I`m home I gonna try the code
So much thanks for this support
Similar Topics
- Concentric circles (Donut SVG style)
HTML - CSS
First post
Hi all,
First of all, thank you to this community for giving life to a wonderful place to share & learn about HTML & CSS.
I would like...
Last post
Hi MarPlo,
thank you!! That works perfectly. I notice that you also changed the width and height to be 500px instead of the 100% that I had in my...