Meta keyword met if en echo
Een vraag dit is mijn huidige meta keyword php code:
Deze geldt voor alle pagina's.
Nu wil ik graag dat wanneer je op de home pagina (index.php) bent het bovenstaande pakt, maar wanneer je op de category pagina bent dat het script de categorienaam pakt <h1>'. $rowrub['titel'] .'</h1>
Ik neem aan dat ik dit met if en echo doe, maar kom er niet goed uit.
Sorry ben een beginnende programmeur (-:
Gewijzigd op 23/06/2014 15:06:57 door - Ariën -
Gewijzigd op 23/06/2014 15:46:12 door JR Wessels Boer
Hoe onderscheid je de pagina's van elkaar in de URL?
Code (php)
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
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
<?php
[code]<?php session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php include("config.php"); ?>
<?php include("paginas.php"); ?>
<head>
<title><?php echo $titel;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="<?php echo $keywords;?>" />
<meta name="description" content="<?php echo $description;?>" />
<meta http-equiv="content-language" content="nl-nl" />
<meta name="robots" content="index, follow" />
<meta name="revisit-after" content="7 days" />
<link rel="shortcut icon" href="/favicon.ico " type="image/x-icon" />
<link href="/css/style.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="/css/shadowbox-light.css" />
<link rel="stylesheet" type="text/css" href="/css/cookie.css" />
<script type="text/javascript" src="/js/cookiewarning.js"></script>
<script type="text/javascript" src="/js/yui-utilities.js"></script>
<script type="text/javascript" src="/js/shadowbox-yui.js"></script>
<script type="text/javascript" src="/js/shadowbox.js"></script>
<script type="text/javascript">
window.onload = Shadowbox.init;
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount','<?php echo"" .$Analyticscode."";?>']);
_gaq.push(['_trackPageview'],['_trackPageLoadTime']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<?php
function chopstring( $string, $maxlength = 250, $append = '...' )
{
$strlen = strlen( $string );
$maxlength = (int) $maxlength;
if( $strlen <= (int) $maxlength )
return $string;
$chopped = substr( $string, 0, $maxlength );
$chopped_on_space = substr( $chopped, 0, strrpos( $chopped, ' ' ) );
return ( $chopped_on_space ) . $append;
}
?>
<div id="container">
<div id="header"><a href="/"><img src="/images/header.png" width="1014" height="200" alt="Header" /></a></div>
<div id="navigation">
<ul>
<?php include($menu); ?>
<div id="addthis">
<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
<a class="addthis_button_preferred_1"></a> <a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a> <a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a> </div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4fe9ea5425bccd10"></script>
<!-- AddThis Button END -->
</div>
<div id="zoeken">
<form action="<?= $Website; ?>/zoeken/" method="post" name="zoeken_form">
<input type="text" name="zoeken_term" id="zoeken_term" value="Uw zoekterm..." onfocus="this.value=''" />
<input type="submit" name="zoeken_submit" id="zoeken_submit" value="Zoeken" />
</form>
</div>
</ul>
</div>
<div id="subcontainer">
<div id="left">
<?php include("menu.php"); ?>
<?php include($left); ?>
</div>
<div id="center">
<?php include($pagina); ?>
</div>
<div id="right">
<?php include($right); ?>
</div>
<?php include("footer.php"); ?>
?>
[code]<?php session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php include("config.php"); ?>
<?php include("paginas.php"); ?>
<head>
<title><?php echo $titel;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="<?php echo $keywords;?>" />
<meta name="description" content="<?php echo $description;?>" />
<meta http-equiv="content-language" content="nl-nl" />
<meta name="robots" content="index, follow" />
<meta name="revisit-after" content="7 days" />
<link rel="shortcut icon" href="/favicon.ico " type="image/x-icon" />
<link href="/css/style.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="/css/shadowbox-light.css" />
<link rel="stylesheet" type="text/css" href="/css/cookie.css" />
<script type="text/javascript" src="/js/cookiewarning.js"></script>
<script type="text/javascript" src="/js/yui-utilities.js"></script>
<script type="text/javascript" src="/js/shadowbox-yui.js"></script>
<script type="text/javascript" src="/js/shadowbox.js"></script>
<script type="text/javascript">
window.onload = Shadowbox.init;
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount','<?php echo"" .$Analyticscode."";?>']);
_gaq.push(['_trackPageview'],['_trackPageLoadTime']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<?php
function chopstring( $string, $maxlength = 250, $append = '...' )
{
$strlen = strlen( $string );
$maxlength = (int) $maxlength;
if( $strlen <= (int) $maxlength )
return $string;
$chopped = substr( $string, 0, $maxlength );
$chopped_on_space = substr( $chopped, 0, strrpos( $chopped, ' ' ) );
return ( $chopped_on_space ) . $append;
}
?>
<div id="container">
<div id="header"><a href="/"><img src="/images/header.png" width="1014" height="200" alt="Header" /></a></div>
<div id="navigation">
<ul>
<?php include($menu); ?>
<div id="addthis">
<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
<a class="addthis_button_preferred_1"></a> <a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a> <a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a> </div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4fe9ea5425bccd10"></script>
<!-- AddThis Button END -->
</div>
<div id="zoeken">
<form action="<?= $Website; ?>/zoeken/" method="post" name="zoeken_form">
<input type="text" name="zoeken_term" id="zoeken_term" value="Uw zoekterm..." onfocus="this.value=''" />
<input type="submit" name="zoeken_submit" id="zoeken_submit" value="Zoeken" />
</form>
</div>
</ul>
</div>
<div id="subcontainer">
<div id="left">
<?php include("menu.php"); ?>
<?php include($left); ?>
</div>
<div id="center">
<?php include($pagina); ?>
</div>
<div id="right">
<?php include($right); ?>
</div>
<?php include("footer.php"); ?>
?>
Gewijzigd op 23/06/2014 15:56:51 door JR Wessels Boer
Hoe ziet je URL er uit als je naar de categorieen gaat?
www.website.nl/categorienaam.html
Dit is de pagina die dan ingeladen wordt:
Code (php)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
$rubriek = addslashes($_GET["rubriek"]);
$rubriekm = strtolower(str_replace('_',' ',$rubriek));
$sqlrub = "SELECT * FROM rubrieken WHERE rubriek = '$rubriekm'";
$resrub = mysql_query($sqlrub);
$rowrub = mysql_fetch_array($resrub);
if($rowrub['titel'] != "")
{
echo'
<img class="top" src="/images/largeTop.jpg" alt="" width="567" height="2" />
<div class="largeTitle">
<h1>'. $rowrub['titel'] .'</h1></div>
<div id="maincontent">
<div class="dottedLine"></div>
<p><h2 style="font-size:14px; color: #000000; font-weight:normal; text-align:left;">'. $rowrub['omschrijving'] .'</h2></p>
</div>
<img class="bottom" src="/images/largeBottom.jpg" alt="" width="567" height="2" />
';
}
$nopic = "/images/nopic.png";
$res = mysql_query("SELECT * FROM instellingen");
while ($obj = mysql_fetch_object($res)) {
$items = $obj->items;
}
$pnr = $_GET['p'];
$hoe = $_GET['hoe'];
if (is_numeric($pnr) && $pnr !== "1") {
$reken1 = (($items*$pnr) - $items);
$reken2 = $items;
} else {
$reken1 =0;
$reken2 =$items;
}
$sort1 = "id";
$hoe = "ASC";
$p ="lIMIT ".$reken1.",".$reken2;
$sql = " SELECT c.*, r.rubriek as rubriek FROM csvfeed c
inner join rubrieken r on c.rubriek = r.id
WHERE r.rubriek = '$rubrieks' ORDER BY $sort1 $hoe $p";
$res = mysql_query($sql);
if (mysql_num_rows($res) >= 1)
{
echo"<div id=\"koopjes\">";
while ($row = mysql_fetch_array($res))
{
$string = '' . $row[description] . '';
$string = str_replace('<br />',' - ',$string);
$string = str_replace('<div>','',$string);
$string = str_replace('</div>','',$string);
$string1 = '' . $row[name] . '';
$string1 = ucfirst(str_replace('-',' ',$string1));
$strc = strtolower(str_replace(' ','_',$row['rubriek']));
$array = array('<', '>', '\\', '/', '=', '!', ',', '?', '.', '%');
$strc = str_replace($array, "", $strc);
$strn = strtolower(str_replace(' ','_',$row['seoname']));
$strv = strtolower(str_replace(' ','_',$row['volgnummer']));
echo "<div class=\"koopje\">
<div class=\"koopjesTitle\"><h2>" . chopstring( $string1, 20 ) . "</h2> </div>
<div class=\"priceBulletin\">";
echo"€ " . $row['price'] ."";
echo"</div>";
echo"<div class=\"koopjesText\">";
echo"<div class=\"koopjesTextImg\">";
if($row['imagesurl'] != "")
{
echo "<a href=\"" . $Website . "/".$strc."/".$strn."".$strv.".html\"><img src=\"" . $row['imagesurl'] . "\" alt=\"" . chopstring( $string1, 100 ) . "\"></a>";
}
else
{
echo "<a href=\"" . $Website . "/".$strc."/".$strn."".$strv.".html\"><img src=" . $nopic ." alt=\"" . chopstring( $string1, 100 ) . "\"></a>";
}
echo"</div>";
echo "<p>" . chopstring( $string, 90 ) . "</p>
<div id=btnDetails><a href=\"" . $Website . "/".$strc."/".$strd."/".$strn."".$strv.".html\" title=\"" . $row['name'] ."\">Details</a></div>
</div>
</div>";
}
echo"</div>";
}
if($rowrub['titel'] != "")
{
echo'
<img class="top" src="/images/largeTop.jpg" alt="" width="567" height="2" />
<div id="maincontent">
<p><h3 style="font-size:14px; color: #000000; font-weight:normal; text-align:left;">'. $rowrub['omschrijving'] .'</h3></p>
</div>
<img class="bottom" src="/images/largeBottom.jpg" alt="" width="567" height="2" />
';
}
echo "<div id=nummering>";
$query = mysql_query(" SELECT c.id FROM csvfeed c
inner join rubrieken r on c.rubriek = r.id
WHERE r.rubriek = '$rubrieks'");
$aantal = mysql_num_rows($query);
$aantal2 = ceil($aantal / $items);
if ($_GET['p'] != 0 && $_GET['p'] != 1) {
$special = 1;
echo "<a href=\"?p=".($_GET['p'] - 1)."\"> «« <b>Vorige</b></a> | ";
}
$done1 = 0;
for ($i = 1; $i < ($aantal2 + 1); $i++)
{
$huidig = $_GET["p"];
$begin = $huidig-2;
$eind = $huidig+7;
$obj = $i + 1;
if($obj < $begin && $done1 == 0)
{
echo "<a href=?p=1>1</a> ... | ";
$done1 = 1;
}
if($i >= $begin && $i <= $eind && $obj > $begin)
{
if($i == $huidig)
{
echo"<a href=\"?p=".$i."\"><b>".$i."</b></a> | ";
}
else
{
echo"<a href=\"?p=".$i."\">".$i."</a> | ";
}
}
$last = $i;
}
if($last > $eind)
{
echo "... <a href=?p=$last>$last</a> ";
}
if (isset($_GET['p']))
{
$volgende = $_GET['p'] + 1;
} else
{
$volgende = 2;
}
if ($volgende <= $last) {
echo "<a href=\"?p=".$volgende."\"> <b>Volgende</b> »» </a>";
}
echo "</div>";
echo "<br clear=all />";
?>
$rubriek = addslashes($_GET["rubriek"]);
$rubriekm = strtolower(str_replace('_',' ',$rubriek));
$sqlrub = "SELECT * FROM rubrieken WHERE rubriek = '$rubriekm'";
$resrub = mysql_query($sqlrub);
$rowrub = mysql_fetch_array($resrub);
if($rowrub['titel'] != "")
{
echo'
<img class="top" src="/images/largeTop.jpg" alt="" width="567" height="2" />
<div class="largeTitle">
<h1>'. $rowrub['titel'] .'</h1></div>
<div id="maincontent">
<div class="dottedLine"></div>
<p><h2 style="font-size:14px; color: #000000; font-weight:normal; text-align:left;">'. $rowrub['omschrijving'] .'</h2></p>
</div>
<img class="bottom" src="/images/largeBottom.jpg" alt="" width="567" height="2" />
';
}
$nopic = "/images/nopic.png";
$res = mysql_query("SELECT * FROM instellingen");
while ($obj = mysql_fetch_object($res)) {
$items = $obj->items;
}
$pnr = $_GET['p'];
$hoe = $_GET['hoe'];
if (is_numeric($pnr) && $pnr !== "1") {
$reken1 = (($items*$pnr) - $items);
$reken2 = $items;
} else {
$reken1 =0;
$reken2 =$items;
}
$sort1 = "id";
$hoe = "ASC";
$p ="lIMIT ".$reken1.",".$reken2;
$sql = " SELECT c.*, r.rubriek as rubriek FROM csvfeed c
inner join rubrieken r on c.rubriek = r.id
WHERE r.rubriek = '$rubrieks' ORDER BY $sort1 $hoe $p";
$res = mysql_query($sql);
if (mysql_num_rows($res) >= 1)
{
echo"<div id=\"koopjes\">";
while ($row = mysql_fetch_array($res))
{
$string = '' . $row[description] . '';
$string = str_replace('<br />',' - ',$string);
$string = str_replace('<div>','',$string);
$string = str_replace('</div>','',$string);
$string1 = '' . $row[name] . '';
$string1 = ucfirst(str_replace('-',' ',$string1));
$strc = strtolower(str_replace(' ','_',$row['rubriek']));
$array = array('<', '>', '\\', '/', '=', '!', ',', '?', '.', '%');
$strc = str_replace($array, "", $strc);
$strn = strtolower(str_replace(' ','_',$row['seoname']));
$strv = strtolower(str_replace(' ','_',$row['volgnummer']));
echo "<div class=\"koopje\">
<div class=\"koopjesTitle\"><h2>" . chopstring( $string1, 20 ) . "</h2> </div>
<div class=\"priceBulletin\">";
echo"€ " . $row['price'] ."";
echo"</div>";
echo"<div class=\"koopjesText\">";
echo"<div class=\"koopjesTextImg\">";
if($row['imagesurl'] != "")
{
echo "<a href=\"" . $Website . "/".$strc."/".$strn."".$strv.".html\"><img src=\"" . $row['imagesurl'] . "\" alt=\"" . chopstring( $string1, 100 ) . "\"></a>";
}
else
{
echo "<a href=\"" . $Website . "/".$strc."/".$strn."".$strv.".html\"><img src=" . $nopic ." alt=\"" . chopstring( $string1, 100 ) . "\"></a>";
}
echo"</div>";
echo "<p>" . chopstring( $string, 90 ) . "</p>
<div id=btnDetails><a href=\"" . $Website . "/".$strc."/".$strd."/".$strn."".$strv.".html\" title=\"" . $row['name'] ."\">Details</a></div>
</div>
</div>";
}
echo"</div>";
}
if($rowrub['titel'] != "")
{
echo'
<img class="top" src="/images/largeTop.jpg" alt="" width="567" height="2" />
<div id="maincontent">
<p><h3 style="font-size:14px; color: #000000; font-weight:normal; text-align:left;">'. $rowrub['omschrijving'] .'</h3></p>
</div>
<img class="bottom" src="/images/largeBottom.jpg" alt="" width="567" height="2" />
';
}
echo "<div id=nummering>";
$query = mysql_query(" SELECT c.id FROM csvfeed c
inner join rubrieken r on c.rubriek = r.id
WHERE r.rubriek = '$rubrieks'");
$aantal = mysql_num_rows($query);
$aantal2 = ceil($aantal / $items);
if ($_GET['p'] != 0 && $_GET['p'] != 1) {
$special = 1;
echo "<a href=\"?p=".($_GET['p'] - 1)."\"> «« <b>Vorige</b></a> | ";
}
$done1 = 0;
for ($i = 1; $i < ($aantal2 + 1); $i++)
{
$huidig = $_GET["p"];
$begin = $huidig-2;
$eind = $huidig+7;
$obj = $i + 1;
if($obj < $begin && $done1 == 0)
{
echo "<a href=?p=1>1</a> ... | ";
$done1 = 1;
}
if($i >= $begin && $i <= $eind && $obj > $begin)
{
if($i == $huidig)
{
echo"<a href=\"?p=".$i."\"><b>".$i."</b></a> | ";
}
else
{
echo"<a href=\"?p=".$i."\">".$i."</a> | ";
}
}
$last = $i;
}
if($last > $eind)
{
echo "... <a href=?p=$last>$last</a> ";
}
if (isset($_GET['p']))
{
$volgende = $_GET['p'] + 1;
} else
{
$volgende = 2;
}
if ($volgende <= $last) {
echo "<a href=\"?p=".$volgende."\"> <b>Volgende</b> »» </a>";
}
echo "</div>";
echo "<br clear=all />";
?>
Gewijzigd op 23/06/2014 16:14:00 door - Ariën -