Hallo,
Hab ein kleines Problem bei meiner Homepage. Für einen Kenner ist das sicher keine Aufgabe, ich als Anfänger habe jedoch meine liebe Not damit meinen PHP Besucherzähler in das css Script einzufügen. Auf der Homepage wird der nämlich als Text angezeigt, und nicht wie vorgesehen nur die Besucheranzahl. Ich arbeite übrigens mit xampp... Hilft mir bitte jemand?
Danke im Voraus.
Besucherzähler:
<?php
$dateiname = "./zaehler.txt";
//Es wird geprüft, ob die Zählerdatei schon vorhanden ist
if(file_exists($dateiname))
{
//Datei existiert bereits, der Inhalt wird in ein Array geladen
$inhalt = file($dateiname);
//Der Zählwert wird aus der Zeichenkette extrahiert
$alter_wert = 0;
sscanf($inhalt[0],"%u",$alter_wert);
//Der Zählwert wird inkrementiert
$alter_wert += 1;
//Der Zählwert wird wieder als Zeichenkette konvertiert
$inhalt[0] = sprintf("%u",$alter_wert);
//Datei wird geöffnet und der neue Wert geschrieben
$fhandle = fopen($dateiname,"w");
//Es wird geprüft, ob die Datei evtl. nicht geöffnet werden konnte
if(!$fhandle)
exit(1);
//Datei konnte geöffnet werden, der neue Wert wird nun geschrieben
fputs($fhandle,$inhalt[0]);
//Datei wird geschlossen
fclose($fhandle);
$dateiname = "./zaehler.txt"; // Name der Datei
$array = file($dateiname); // Datei in ein Array einlesen
foreach ($array as $element) {
echo $element . "<br>"; // Dateiinhalt ausgeben
}
}
else
{
//Datei wird erstellt und der Wert 1 geschrieben
$fhandle = fopen($dateiname,"a");
//Es wird geprüft, ob die Datei evtl. nicht erstellt werden konnte
if(!$fhandle)
exit(1);
//Datei konnte erstellt werden, der Wert 1 wird nun geschrieben
fputs($fhandle,"1");
//Datei wird geschlossen
fclose($fhandle);
$dateiname = "./zaehler.txt"; // Name der Datei
$array = file($dateiname); // Datei in ein Array einlesen
foreach ($array as $element) {
echo $element . "<br>"; // Dateiinhalt ausgeben
}
}
?>
CSS Script:
margin: 7% auto;
padding:0px;
width:1126px;
background-image:url(img/background.jpg);
background-repeat:no-repeat;
background-attachment:fixed;
}
#main{
background:#e4e4e4;
height:1200px;
width:1126px;
}
.box1{
background-image:url(img/top.jpg);
height:250px;
width:100%;
}
/* CSS für das Menü */
.menu_container {
margin: 0 auto 20px auto;
position: relative;
width: 1126px;
height: 20px;
z-index: 100;
}
.menu, .menu ul {
padding: 0;
margin: 0;
list-style: none;
position: absolute;
}
.menu ul {
left: -9999px;
width: 125px;
padding: 0 20px 20px 20px;
}
.menu ul ul {
padding: 20px 20px 20px 0;
}
.menu a {
display: block;
width: 124px;
padding-left: 0px;
text-align: center;
font: normal bold 14px/40px arial, sans-serif;
color: #fff;
text-decoration: none;
margin: 0 -1px -1px 0;
background-color: #283daf;
color: white;
border-right: 1px solid grey;
border-left: 1px solid grey;
}
.menu li ul a {
font-weight: bold;
height:29px;
padding-top 0px;
border-bottom: 1px solid grey;
border-top: 1px solid grey;
border-right: 1px solid grey;
border-left: 1px solid grey;
background-color: white;
color: grey;
}
.menu li {
float: left;
border-right:1px
}
.menu li a {
}
.menu li:hover {
position: relative;
z-index: 100;
}
.menu li:hover > a {
background-color: #000080;
color: white;
}
.menu li:hover > ul {
top: 40px;
left: -20px;
z-index: -1;
}
.menu li:hover li:hover > a {
background-color:#e4e4e4;
color: #000080;
border: 2px solid grey;
}
.menu li:hover li:hover > ul {
left: 145px;
top: -20px;
z-index: 100;
}
.menu li.right:hover li:hover > ul {
left: -165px;
top: -20px;
z-index: 100;
padding: 20px 0 20px 20px;
}
.box3{
background-image:url(img/transition.jpg);
float:left;
padding:0px;
width:19%;
height:900px;
margin:5px;
}
.flashclass{ /*sample CSS class added to image slideshow container*/
width: 200px; /*a width should be defined for transition to work*/
margin: 50px auto;
}
.flashclass img{
border-width: 0;
}
.animclass{ /*sample CSS class added to image slideshow container*/
width: 200px; /*a width should be defined for transition to work*/
margin: 5px auto;
}
.animclass img{
border-width: 0;
}
.box4{
background:darkgray;
float:left;
margin:5px;
padding:0px;
}
.box5{
background:gray;
float:left;
width:1126px;
position:absolute;
top:1339px;
}
Hab ein kleines Problem bei meiner Homepage. Für einen Kenner ist das sicher keine Aufgabe, ich als Anfänger habe jedoch meine liebe Not damit meinen PHP Besucherzähler in das css Script einzufügen. Auf der Homepage wird der nämlich als Text angezeigt, und nicht wie vorgesehen nur die Besucheranzahl. Ich arbeite übrigens mit xampp... Hilft mir bitte jemand?
Danke im Voraus.
Besucherzähler:
<?php
$dateiname = "./zaehler.txt";
//Es wird geprüft, ob die Zählerdatei schon vorhanden ist
if(file_exists($dateiname))
{
//Datei existiert bereits, der Inhalt wird in ein Array geladen
$inhalt = file($dateiname);
//Der Zählwert wird aus der Zeichenkette extrahiert
$alter_wert = 0;
sscanf($inhalt[0],"%u",$alter_wert);
//Der Zählwert wird inkrementiert
$alter_wert += 1;
//Der Zählwert wird wieder als Zeichenkette konvertiert
$inhalt[0] = sprintf("%u",$alter_wert);
//Datei wird geöffnet und der neue Wert geschrieben
$fhandle = fopen($dateiname,"w");
//Es wird geprüft, ob die Datei evtl. nicht geöffnet werden konnte
if(!$fhandle)
exit(1);
//Datei konnte geöffnet werden, der neue Wert wird nun geschrieben
fputs($fhandle,$inhalt[0]);
//Datei wird geschlossen
fclose($fhandle);
$dateiname = "./zaehler.txt"; // Name der Datei
$array = file($dateiname); // Datei in ein Array einlesen
foreach ($array as $element) {
echo $element . "<br>"; // Dateiinhalt ausgeben
}
}
else
{
//Datei wird erstellt und der Wert 1 geschrieben
$fhandle = fopen($dateiname,"a");
//Es wird geprüft, ob die Datei evtl. nicht erstellt werden konnte
if(!$fhandle)
exit(1);
//Datei konnte erstellt werden, der Wert 1 wird nun geschrieben
fputs($fhandle,"1");
//Datei wird geschlossen
fclose($fhandle);
$dateiname = "./zaehler.txt"; // Name der Datei
$array = file($dateiname); // Datei in ein Array einlesen
foreach ($array as $element) {
echo $element . "<br>"; // Dateiinhalt ausgeben
}
}
?>
CSS Script:
margin: 7% auto;
padding:0px;
width:1126px;
background-image:url(img/background.jpg);
background-repeat:no-repeat;
background-attachment:fixed;
}
#main{
background:#e4e4e4;
height:1200px;
width:1126px;
}
.box1{
background-image:url(img/top.jpg);
height:250px;
width:100%;
}
/* CSS für das Menü */
.menu_container {
margin: 0 auto 20px auto;
position: relative;
width: 1126px;
height: 20px;
z-index: 100;
}
.menu, .menu ul {
padding: 0;
margin: 0;
list-style: none;
position: absolute;
}
.menu ul {
left: -9999px;
width: 125px;
padding: 0 20px 20px 20px;
}
.menu ul ul {
padding: 20px 20px 20px 0;
}
.menu a {
display: block;
width: 124px;
padding-left: 0px;
text-align: center;
font: normal bold 14px/40px arial, sans-serif;
color: #fff;
text-decoration: none;
margin: 0 -1px -1px 0;
background-color: #283daf;
color: white;
border-right: 1px solid grey;
border-left: 1px solid grey;
}
.menu li ul a {
font-weight: bold;
height:29px;
padding-top 0px;
border-bottom: 1px solid grey;
border-top: 1px solid grey;
border-right: 1px solid grey;
border-left: 1px solid grey;
background-color: white;
color: grey;
}
.menu li {
float: left;
border-right:1px
}
.menu li a {
}
.menu li:hover {
position: relative;
z-index: 100;
}
.menu li:hover > a {
background-color: #000080;
color: white;
}
.menu li:hover > ul {
top: 40px;
left: -20px;
z-index: -1;
}
.menu li:hover li:hover > a {
background-color:#e4e4e4;
color: #000080;
border: 2px solid grey;
}
.menu li:hover li:hover > ul {
left: 145px;
top: -20px;
z-index: 100;
}
.menu li.right:hover li:hover > ul {
left: -165px;
top: -20px;
z-index: 100;
padding: 20px 0 20px 20px;
}
.box3{
background-image:url(img/transition.jpg);
float:left;
padding:0px;
width:19%;
height:900px;
margin:5px;
}
.flashclass{ /*sample CSS class added to image slideshow container*/
width: 200px; /*a width should be defined for transition to work*/
margin: 50px auto;
}
.flashclass img{
border-width: 0;
}
.animclass{ /*sample CSS class added to image slideshow container*/
width: 200px; /*a width should be defined for transition to work*/
margin: 5px auto;
}
.animclass img{
border-width: 0;
}
.box4{
background:darkgray;
float:left;
margin:5px;
padding:0px;
}
.box5{
background:gray;
float:left;
width:1126px;
position:absolute;
top:1339px;
}