inserire variabile php colore in div html

AndreaCerre

Utente Attivo
7 Giu 2020
55
0
6
Ciao a tutti,

avrei bisogno di un aiuto riguardo alla sintassi corrette per inserire questa variabile {$row['colore']}"

al posto del codice esadecimale presente in questo punto: fill='#28a745'


Codice:
<?php
$resource = $mysqli->query("SELECT firstname, lastname, colore FROM utenti_cavour2a where tipo_utente='proprietario'");

while ( $row = $resource->fetch_assoc() ) {


echo "<div class='media text-muted pt-3'> <svg class='bd-placeholder-img mr-2 rounded' width='32' height='32' xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='xMidYMid sliceì focusable='false' role='img' aria-label='Placeholder: 32x32'><title>Placeholder</title><rect width='100%' height='100%' fill='#28a745'/><text x='50%' y='50%' fill='#28a745' dy='.3em'>32x32</text></svg> <p class='media-body pb-3 mb-0 small lh-125 border-bottom border-gray'>
        <strong class='d-block text-gray-dark'>" . "{$row['firstname']}" . " " . "{$row['lastname']}" . " </strong>
        Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
      </p>
    </div>";


}

?>
 
Prova così:
PHP:
...height='100%' fill='".$row['colore']."'/><text x='50%'...
Oppure dai un nome alla variabile e poi la metti direttamente dentro:
PHP:
$colore = $row['colore'];
...height='100%' fill='$colore'/><text x='50%'...
 

Discussioni simili