I'm building a few simple CMS variables into an Dynamic site that I half-built with Dreamweaver. The following code is the initiation of a paginated recordset display generated by Dreamweaver:

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_creditsList = 6;
$pageNum_creditsList = 0;
if (isset($_GET['pageNum_creditsList'])) {
  $pageNum_creditsList = $_GET['pageNum_creditsList'];
}
$startRow_creditsList = $pageNum_creditsList * $maxRows_creditsList;

mysql_select_db($database_conSkye, $conSkye);
$query_creditsList = "SELECT title, `year`, `role`, flv, link FROM media ORDER BY `orda` DESC";
$query_limit_creditsList = sprintf("%s LIMIT %d, %d", $query_creditsList, $startRow_creditsList, $maxRows_creditsList);
$creditsList = mysql_query($query_limit_creditsList, $conSkye) or die(mysql_error());
$row_creditsList = mysql_fetch_assoc($creditsList);

if (isset($_GET['totalRows_creditsList'])) {
  $totalRows_creditsList = $_GET['totalRows_creditsList'];
} else {
  $all_creditsList = mysql_query($query_creditsList);
  $totalRows_creditsList = mysql_num_rows($all_creditsList);
}
$totalPages_creditsList = ceil($totalRows_creditsList/$maxRows_creditsList)-1;

What I want to do is swap the value here:

$maxRows_creditsList = 6;

...for something like this:

$maxRows_creditsList = $valueFromDb;

This is just one variable in a table (cms_vars) that contains 2 columns; (variable_name), and (variable_value). I tried this but it didn't seem to work:

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_creditsList = $mediarows;
$pageNum_creditsList = 0;
if (isset($_GET['pageNum_creditsList'])) {
  $pageNum_creditsList = $_GET['pageNum_creditsList'];
}
$startRow_creditsList = $pageNum_creditsList * $maxRows_creditsList;

mysql_select_db($database_conSkye, $conSkye);
[B]$mediarows = "SELECT variable_value FROM cms_vars WHERE variable_name='medialist_rows'";
if (!mysql_query($mediarows,$conSkye))
  {
  die('Errorrr: ' . mysql_error());
  } [/B]
$query_creditsList = "SELECT title, `year`, `role`, flv, link FROM media ORDER BY `orda` DESC";
$query_limit_creditsList = sprintf("%s LIMIT %d, %d", $query_creditsList, $startRow_creditsList, $maxRows_creditsList);
$creditsList = mysql_query($query_limit_creditsList, $conSkye) or die(mysql_error());
$row_creditsList = mysql_fetch_assoc($creditsList);

if (isset($_GET['totalRows_creditsList'])) {
  $totalRows_creditsList = $_GET['totalRows_creditsList'];
} else {
  $all_creditsList = mysql_query($query_creditsList);
  $totalRows_creditsList = mysql_num_rows($all_creditsList);
}
$totalPages_creditsList = ceil($totalRows_creditsList/$maxRows_creditsList)-1;

Query the database for the value you want to substitute.

$new_value=mysql_query("SELECT something FROM cms_vars WHERE something='$something_else' ");
while($nv=mysql_fetch_array($new_value)) {
$valueFromDb = $nv['variable_value']; }

$maxRows_creditsList = $valueFromDb;

Unless I'm missing something here this would work just fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.