PHP catalogus
Ik ben een nieuwe website aan het bouwen en leer iedere dag meer een meer van PHP en mysql. Ik probeer een catalogus te maken http://www.estero-travel.com/nl/accommodaties.php
Op zich lukt dat ook, maar nu zoek ik de oplossing ervoor dat ik graag bovenaan de links wil gebruiken dat de bezoekers de catalogus zelf kunnen laten sorteren op plaats, of prijs o.i.d.
Kan me iemand ermee helpen ?
Bedankt voor je snelle antwoord. nu heb ik de query zo staan dat het al automatisch op de prijs (laagste als eerst) sorteerd, maar mij gaat het erom dat de bezoeker zelf kan sorteren. Hoe moet ik de query die jij noemt dan inbouwen ? Sorry snap het ff niet....
Mijn php codes zien als volgt uit
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
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
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_accos = 5;
$pageNum_accos = 0;
if (isset($_GET['pageNum_accos'])) {
$pageNum_accos = $_GET['pageNum_accos'];
}
$startRow_accos = $pageNum_accos * $maxRows_accos;
mysql_select_db($database_db, $db);
$query_accos = "SELECT * FROM accos ORDER BY price_from ASC";
$query_limit_accos = sprintf("%s LIMIT %d, %d", $query_accos, $startRow_accos, $maxRows_accos);
$accos = mysql_query($query_limit_accos, $db) or die(mysql_error());
$row_accos = mysql_fetch_assoc($accos);
if (isset($_GET['totalRows_accos'])) {
$totalRows_accos = $_GET['totalRows_accos'];
} else {
$all_accos = mysql_query($query_accos);
$totalRows_accos = mysql_num_rows($all_accos);
}
$totalPages_accos = ceil($totalRows_accos/$maxRows_accos)-1;
$queryString_accos = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_accos") == false &&
stristr($param, "totalRows_accos") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_accos = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_accos = sprintf("&totalRows_accos=%d%s", $totalRows_accos, $queryString_accos);
?>
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_accos = 5;
$pageNum_accos = 0;
if (isset($_GET['pageNum_accos'])) {
$pageNum_accos = $_GET['pageNum_accos'];
}
$startRow_accos = $pageNum_accos * $maxRows_accos;
mysql_select_db($database_db, $db);
$query_accos = "SELECT * FROM accos ORDER BY price_from ASC";
$query_limit_accos = sprintf("%s LIMIT %d, %d", $query_accos, $startRow_accos, $maxRows_accos);
$accos = mysql_query($query_limit_accos, $db) or die(mysql_error());
$row_accos = mysql_fetch_assoc($accos);
if (isset($_GET['totalRows_accos'])) {
$totalRows_accos = $_GET['totalRows_accos'];
} else {
$all_accos = mysql_query($query_accos);
$totalRows_accos = mysql_num_rows($all_accos);
}
$totalPages_accos = ceil($totalRows_accos/$maxRows_accos)-1;
$queryString_accos = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_accos") == false &&
stristr($param, "totalRows_accos") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_accos = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_accos = sprintf("&totalRows_accos=%d%s", $totalRows_accos, $queryString_accos);
?>
bedankt ,...en kan je me ook helpen met de script ?