我怎么能在顶部的类别中添加最新的电影,因为当我添加下来

时间:2013-01-14 18:01:41

标签: php

我怎么能把最新的电影放在列表的顶部,因为当我添加新电影时我想要做出像ORDER by Id Desc那样的想法,但是怎么样,我在php上这个代码是由dreamweaver cs5创建的,可以帮助我用一段代码来添加推杆顶部吗?

<?php require_once('Connections/filmconnexion.php'); ?>
    <?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;
    }
    }

    $maxRows_DataCategoria = 12;
    $pageNum_DataCategoria = 0;
    if (isset($_GET['pageNum_DataCategoria'])) {
      $pageNum_DataCategoria = $_GET['pageNum_DataCategoria'];
    }
    $startRow_DataCategoria = $pageNum_DataCategoria * $maxRows_DataCategoria;

    $varCategoria_DataCategoria = "0";
    if (isset($_GET["cat"])) {
      $varCategoria_DataCategoria = $_GET["cat"];
    }
    mysql_select_db($database_filmconnexion, $filmconnexion);
    $query_DataCategoria = sprintf("SELECT * FROM tbl_film WHERE tbl_film.intCategoria = %s ", GetSQLValueString($varCategoria_DataCategoria, "int"));
    $query_limit_DataCategoria = sprintf("%s LIMIT %d, %d", $query_DataCategoria, $startRow_DataCategoria, $maxRows_DataCategoria);
    $DataCategoria = mysql_query($query_limit_DataCategoria, $filmconnexion) or die(mysql_error());
    $row_DataCategoria = mysql_fetch_assoc($DataCategoria);

    if (isset($_GET['totalRows_DataCategoria'])) {
      $totalRows_DataCategoria = $_GET['totalRows_DataCategoria'];
    } else {
      $all_DataCategoria = mysql_query($query_DataCategoria);
      $totalRows_DataCategoria = mysql_num_rows($all_DataCategoria);
    }
    $totalPages_DataCategoria = ceil($totalRows_DataCategoria/$maxRows_DataCategoria)-1;
    ?>

1 个答案:

答案 0 :(得分:0)

更改此行代码

$query_limit_DataCategoria = sprintf("%s ORDER BY id DESC LIMIT %d, %d", $query_DataCategoria, $startRow_DataCategoria, $maxRows_DataCategoria);