- Home
- Categorie
- Coding e Sistemistica
- PHP
- nuova scelta colori da database
-
nuova scelta colori da database
salve ragazzi mi sto ingavettando un pò...
ho modificato dalla mia chat la scelta dei colori.prima c'erano dei temi preimpostati che l'utente sceglieva quale usare nelle pagine c'era questo collegamento :
[PHP]echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";[/PHP]
oggi dopo tanta fatica ho incrementato una funzione dove l'utente sceglie il singolo colore sfondo,link,linee e testo..
che devo eliminare il codice sopra ok,ma con cosa posso sostituirlo in modo che non devo stare a copiarlo e incollarlo ovunque???
grazie a chi mi aiuterà:)
-
usare un include? cosi quando lo modifichi non devi riscriverlo ovunque?
-
[php]
$background = mysql_query('SELECT background FROM ibwf_users WHERE id = "' . $uid . '"');
$background1 = mysql_fetch_array($background, MYSQL_ASSOC);
$background3 = $background1['background'];$background1 = trim($background[0]);
if($background2=="")
{
$background = "000000";
}else{
$background = "$background3";
}
///////////////////////////////
$color = mysql_query('SELECT color FROM ibwf_users WHERE id = "' . $uid . '"');
$color1 = mysql_fetch_array($color, MYSQL_ASSOC);
$color3 = $color1;
///////////////////////////////
$links = mysql_query('SELECT links FROM ibwf_users WHERE id = "' . $uid . '"');
$links1 = mysql_fetch_array($links, MYSQL_ASSOC);
$links3 = $links1['links'];
///////////////////////////////
$line = mysql_query('SELECT line FROM ibwf_users WHERE id = "' . $uid . '"');
$line1 = mysql_fetch_array($line, MYSQL_ASSOC);
$line3 = $line1['line'];
///////////////////////////////
echo "<style type="text/css">\n";
echo "body{\n
background-color: #$background3;\n
font-family: Verdana, Arial, Helvetica, sans-serif;\n
color: #$color3;\n
}
";
echo "a, a:active {\n
color: #$links3;\n
}\n
a:visited {\n
color: #$links3;\n
}\n
a:hover {\n
color: #$links3;
}\n
";
echo "hr {\n
background-color: #$line3;\n
color: #$line3;\n
border: none;\n
height: 1px;\n
}\n";
[/php]
-
questo è il codice nuovo .
se incollassi il nuovo codice in un nuovo documento php includendolo nell'index. questo si ripeterebbe per ogni action=azione o dovrei riincluderlo???
-
praticamente se dopo i tag <title>nome sito</title>
aggiungo:
[php]
$background = mysql_query('SELECT background FROM ibwf_users WHERE id = "' . $uid . '"');
$background1 = mysql_fetch_array($background, MYSQL_ASSOC);
$background3 = $background1['background'];$background1 = trim($background[0]);
if($background2=="")
{
$background = "000000";
}else{
$background = "$background3";
}
///////////////////////////////
$color = mysql_query('SELECT color FROM ibwf_users WHERE id = "' . $uid . '"');
$color1 = mysql_fetch_array($color, MYSQL_ASSOC);
$color3 = $color1;
///////////////////////////////
$links = mysql_query('SELECT links FROM ibwf_users WHERE id = "' . $uid . '"');
$links1 = mysql_fetch_array($links, MYSQL_ASSOC);
$links3 = $links1['links'];
///////////////////////////////
$line = mysql_query('SELECT line FROM ibwf_users WHERE id = "' . $uid . '"');
$line1 = mysql_fetch_array($line, MYSQL_ASSOC);
$line3 = $line1['line'];
///////////////////////////////
echo "<style type="text/css">\n";
echo "body{\n
background-color: #$background3;\n
font-family: Verdana, Arial, Helvetica, sans-serif;\n
color: #$color3;\n
}
";
echo "a, a:active {\n
color: #$links3;\n
}\n
a:visited {\n
color: #$links3;\n
}\n
a:hover {\n
color: #$links3;
}\n
";
echo "hr {\n
background-color: #$line3;\n
color: #$line3;\n
border: none;\n
height: 1px;\n
}\n";echo "</style>\n"; echo "</head>";
[/php]
si vedono i coloro.
però diventa lunga la cosa xche nello script ci sono diverse pagine all'interno fatte da action=nomeazione
e x ogni title devo riincollare quel codice ...non ci sarebbe un modo piu semplice come lo era prima
[php]echo "<link rel="stylesheet" type="text/css" href="../themes/$theme[0]">"; [/php]
grazie
-
fai un include
se nelle pagine hai quel codice ancora puoi usare la funzione cerca e sostituisci con dreamweaver su tutti i file del sito cosi fai subito...
-
l'include con estensione php o css???:?
-
esiste un codice tipo
[PHP]echo "<link rel="stylesheet" type="text/css" href="../themes/$theme[0]">"; [/PHP]
che faccia al mio caso???