PHP script para links no me funciona
Publicado por Joseba (56 intervenciones) el 10/12/2018 11:04:12
Aupa , me idea es hacer lo que hago con javascript https://www.lawebdelprogramador.com/foros/JavaScript/1677563-Javascript-Code-no-me-funciona.html#last , hacerlo con un php Script . Yo quiero que los links cambie de color , cuando este en esa pagina ... .
Yo creo que el problema esta en el Script php ,
el archivo se llama header-beispiel.php , todo el code , que tengo en este archivo..
Luego tengo 3 archivos en php , se llaman beispiel-1.php , beispiel-2.php y beispiel-3.php , que tienen el mismo Code ,
lo unico que cambia en cada uno es en $current_page = "1"; ,que seria $current_page = "1"; , $current_page = "2"; , $current_page = "3"; .
Me podria ayudar algien ha solucionar este problema , gracias !
Yo creo que el problema esta en el Script php ,
1
2
3
4
5
6
7
8
<nav class="link_wechsel">
<h2 class="visually-hidden">Page navigation</h2>
<ul>
<li><a <?php if ($current_page=="1"): ?>aria-current="page" <?php endif;?> href="beispiel-1.php">1</a></li>
<li><a <?php if ($current_page=="2"): ?>aria-current="page" <?php endif ?> href="beispiel-2.php">2</a></li>
<li><a <?php if ($current_page=="3"): ?>aria-current="page" <?php endif ?> href="beispiel-3.php">3</a></li>
</ul>
</nav>
el archivo se llama header-beispiel.php , todo el code , que tengo en este archivo..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
header("Content-Type: text/html; Charset=utf-8");
mb_internal_encoding('UTF-8');
date_default_timezone_set('UTC');
error_reporting(E_ALL);
?>
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>header-beispiel</title>
</head>
<style>
.link_wechsel ul {
list-style-type: none;
margin-left: 340px;
}
.link_wechsel li {
display: inline;
}
.link_wechsel a {
display: inline;
text-decoration: none;
border: 1px solid gray;
background-color: #FE2E64;
color: black;
padding: 8px;
opacity: 0.5;
font-family: Times New Roman;
}
.link_wechsel a:hover {
background-color: #9f9e9e;
}
.link_wechsel a.[aria-current=page] {
background-color:green;
}
.mela a.[aria-current=page] {
background-color:green;
}
</style>
<body>
<nav class="link_wechsel">
<h2 class="visually-hidden">Page navigation</h2>
<ul>
<li><a <?php if ($current_page=="1"): ?>aria-current="page" <?php endif;?> href="beispiel-1.php">1</a></li>
<li><a <?php if ($current_page=="2"): ?>aria-current="page" <?php endif ?> href="beispiel-2.php">2</a></li>
<li><a <?php if ($current_page=="3"): ?>aria-current="page" <?php endif ?> href="beispiel-3.php">3</a></li>
</ul>
</nav>
</body>
</html>
Luego tengo 3 archivos en php , se llaman beispiel-1.php , beispiel-2.php y beispiel-3.php , que tienen el mismo Code ,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
$current_page = "1";
require 'header-beispiel.php';
header("Content-Type: text/html; Charset=utf-8");
mb_internal_encoding('UTF-8');
date_default_timezone_set('UTC');
error_reporting(E_ALL);
?>
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>beispiel-1</title>
</head>
<style>
</style>
<body>
<h3>Page 1</h3>
</body>
</html<
lo unico que cambia en cada uno es en $current_page = "1"; ,que seria $current_page = "1"; , $current_page = "2"; , $current_page = "3"; .
Me podria ayudar algien ha solucionar este problema , gracias !
Valora esta pregunta
1