Hi,
This is probably easier than I think, but I have a question!
I have created a created a page (http://www.12csv.com/main/traction/build/buildlists.php?id=RLQ), which shows all the information I want by changing the id to VF, RLQ or RSH
I have created a separate page to show all records, but I want to just use one page to show all options if possible.
This is the coding used for the page
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_rsBuildLists = 17;
$pageNum_rsBuildLists = 0;
if (isset($_GET['pageNum_rsBuildLists'])) {
$pageNum_rsBuildLists = $_GET['pageNum_rsBuildLists'];
}
$startRow_rsBuildLists = $pageNum_rsBuildLists * $maxRows_rsBuildLists;
$colname_rsBuildLists = "-1";
if (isset($_GET['id'])) {
$colname_rsBuildLists = $_GET['id'];
}
mysql_select_db($database_connGrowl, $connGrowl);
$query_rsBuildLists = sprintf("SELECT * FROM growl_locos WHERE BuildID = %s ORDER BY LocoID ASC", GetSQLValueString($colname_rsBuildLists, "text"));
$query_limit_rsBuildLists = sprintf("%s LIMIT %d, %d", $query_rsBuildLists, $startRow_rsBuildLists, $maxRows_rsBuildLists);
$rsBuildLists = mysql_query($query_limit_rsBuildLists, $connGrowl) or die(mysql_error());
$row_rsBuildLists = mysql_fetch_assoc($rsBuildLists);
if (isset($_GET['totalRows_rsBuildLists'])) {
$totalRows_rsBuildLists = $_GET['totalRows_rsBuildLists'];
} else {
$all_rsBuildLists = mysql_query($query_rsBuildLists);
$totalRows_rsBuildLists = mysql_num_rows($all_rsBuildLists);
}
$totalPages_rsBuildLists = ceil($totalRows_rsBuildLists/$maxRows_rsBuildLists)-1;
$colname_rsLocations = "-1";
if (isset($_GET['id'])) {
$colname_rsLocations = $_GET['id'];
}
mysql_select_db($database_connGrowl, $connGrowl);
$query_rsLocations = sprintf("SELECT * FROM growl_buildloc WHERE locID = %s", GetSQLValueString($colname_rsLocations, "text"));
$rsLocations = mysql_query($query_rsLocations, $connGrowl) or die(mysql_error());
$row_rsLocations = mysql_fetch_assoc($rsLocations);
$totalRows_rsLocations = mysql_num_rows($rsLocations);
$queryString_rsBuildLists = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rsBuildLists") == false &&
stristr($param, "totalRows_rsBuildLists") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rsBuildLists = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rsBuildLists = sprintf("&totalRows_rsBuildLists=%d%s", $totalRows_rsBuildLists, $queryString_rsBuildLists);
$EEG_LimitLinksEndCount = 10;
$EEG_temp = $pageNum_rsBuildLists + 1;
$EEG_startLink = max(1,$EEG_temp - intval($EEG_LimitLinksEndCount/2));
$EEG_temp = $EEG_startLink + $EEG_LimitLinksEndCount - 1;
$EEG_endLink = min($EEG_temp, $totalPages_rsBuildLists + 1);
if($EEG_endLink != $EEG_temp) $EEG_startLink = max(1,$EEG_endLink - $EEG_LimitLinksEndCount + 1);
?>
How could I adapt this code for my needs?
Cheers
Phil