Results 1 to 2 of 2

Thread: Need help to make dinamic pagination

  1. #1
    Join Date
    Feb 2013

    Thumbs up Need help to make dinamic pagination

    i need help to clean sytanx errors a little and to do a pagination for dinamic pages.i give a beer on paypall who helps me at the finish here is my code

    <?php require_once('./Connections/filminitaliano.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";
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    case "double":
    $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    return $theValue;

    $maxRows_listaFilm = 10;
    $pageNum_listaFilm = 0;
    if (isset($_GET['pageNum_listaFilm'])) {
    $pageNum_listaFilm = $_GET['pageNum_listaFilm'];
    $startRow_listaFilm = $pageNum_listaFilm * $maxRows_listaFilm;
    $varCategoria_listaFilm = "0";
    if (isset($_GET['cat']) && $_GET['cat'] > 0 ? (int) $_GET['cat'] : 0){
    $varCategoria_listaFilm = $_GET["cat"];

    else {
    header("Location: genere.php?cat=1/Azione");
    mysql_select_db($database_filminitaliano, $filminitaliano);
    $query_listaFilm = sprintf("SELECT * FROM filme WHERE filme.intCategoria = %s", GetSQLValueString($varCategoria_listaFilm, "int"));
    $query_limit_listaFilm = sprintf("%s LIMIT %d, %d", $query_listaFilm, $startRow_listaFilm, $maxRows_listaFilm);
    $listaFilm = mysql_query($query_limit_listaFilm, $filminitaliano) or die(mysql_error());
    $row_listaFilm = mysql_fetch_assoc($listaFilm);

    if (isset($_GET['totalRows_listaFilm'])) {
    $totalRows_listaFilm = $_GET['totalRows_listaFilm'];
    } else {
    $all_listaFilm = mysql_query($query_listaFilm);
    $totalRows_listaFilm = mysql_num_rows($all_listaFilm);
    $totalPages_listaFilm = ceil($totalRows_listaFilm/$maxRows_listaFilm)-1;


    <!DOCTYPE html>
    <html lang="en">
    <meta charset="utf-8">
    <title>Site Setup</title>

    <meta name="viewport" content="width=device-width">

    <!-- Main stylesheet imports bootstrap css and adds custom -->
    <link href="css/style.css" rel="stylesheet">

    <!-- Modernizr for browser feature-checking
    and HTML5shim (included) see modernizr.com -->
    <script src="js/modernizr-2.5.3.min.js"></script>

    <!-- Fav and touch icons -->
    <!-- OR remove these lines and place icons directly
    in the site root folder mathiasbynens.be/notes/touch-icons -->
    <link rel="shortcut icon" href="img/favicon.ico">
    <link rel="apple-touch-icon" href="img/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72" href="img/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="img/apple-touch-icon-114x114.png">
    <link rel="stylesheet" type="text/css" href="css/demo.css" />
    <link rel="stylesheet" type="text/css" href="css/elastislide.css" />
    <link rel="stylesheet" type="text/css" href="css/custom.css" />
    <script src="js/modernizr.custom.17475.js"></script>



    <div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
    <div class="container">
    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <a class="brand" href="index.html" style="font-family:'alba'; font-size:24px;">Film in italiano.com</a>
    <div class="nav-collapse">
    <ul class="nav">
    <li class="active"><a href="#"><i class="icon-home icon-white"></i> Homepage</a></li>
    <li><a href="#">In Cinema</a></li>
    <li><a href="#">Articoli</a></li>
    <li><a href="#">Accesso utenti</a></li>
    <li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Genere <b class="caret"></b></a>
    <ul class="dropdown-menu">
    <?php include 'inc/listacategoria.php'?>

    <form class="navbar-search pull-right" action="">
    <input type="text" class="search-query span2" placeholder="Search">

    </div><!-- /.nav-collapse -->
    </div><!-- /.container -->
    </div><!-- /navbar-inner -->
    </div><!-- /navbar -->

    <div class="container">

    <div class="container demo-1">
    <!-- Codrops top bar -->
    <!--/ Codrops top bar -->

    <div class="main">
    <header class="clearfix">

    <nav class="codrops-demos">


    <!-- Elastislide Carousel -->



    <table width="100%" border="0">
    <td><?php if ($totalRows_listaFilm > 0) { // Show if recordset not empty ?>
    <?php do { ?>
    <div id="mainwrapper">
    <!-- Image Caption 1 -->

    <div id="box-1" class="box"> <a href="film.php?id=<?php echo mysql_real_escape_string($row_listaFilm['id']); ?>/<?php echo $row_listaFilm['titolo_link']; ?>"><img src="copFilm/descrcare.jpg" width="150" height="199" id="image-1"/></a>
    <span class="caption simple-caption">
    <div style="width:150"><p style="font-size:12px;"><?php echo $row_listaFilm['titolo']; ?></p></div>

    <?php } while ($row_listaFilm = mysql_fetch_assoc($listaFilm)); ?>
    <?php } // Show if recordset not empty ?>
    <?php if ($totalRows_listaFilm == 0) { // Show if recordset empty ?>
    Nessun film in questa categoria
    <?php } // Show if recordset empty ?></td>
    <td>Space for pagination</td>

    </div> <!-- /container -->

    <!-- ==============================================
    JavaScript below! -->

    <!-- jQuery via Google + local fallback, see h5bp.com -->

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="js/jquery-1.7.1.min.js"><\/script>')</script>

    <!-- Bootstrap JS -->
    <script src="js/bootstrap.min.js"></script>

    <!-- Prettify -->
    <script src="js/prettify/prettify.js"></script>

    <!-- Initialize Scripts -->

    addEventListener('load', prettyPrint, false);


    // Activate prettyprint

    // Initialize tabs and pills

    }); // end document.ready
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquerypp.custom.js"></script>
    <script type="text/javascript" src="js/jquery.elastislide.js"></script>
    <script type="text/javascript">

    $( '#carousel' ).elastislide();



  2. #2
    Join Date
    Jan 2012
    It does help a ton if you use the [ code ] or [ php ] BB tags when you post code. There's some handy icons above where you write your post that can help.

    First a bit more information would be helpful to us, like what your code is or is not doing. Are you getting errors if so what are they. If it is not giving an error but is not working you could set "error_reporting(E_ALL)" and you might see the problem or at least it would give us here a clue to the problem.

    I looks like "$_GET['pageNum_listaFilm']" is were you retrieving the page number from but I do not see "pageNum_listaFilm" set anywhere in your HTML. At minimum you need a link like so:
    HTML Code:
    <a href="yourpage.php?pageNum_listaFilm=2">Page 2</a>
    Or a form that has its "method" attribute set to "get" and a field in that form with a "name" of "pageNum_listaFilm".

    Same goes for "$_GET['cat']" I do not see a link or a form field that sets the value of "cat".

    Hope the helps. If not try to provide some more information.

    Lastly a couple things you should do differently. Functions should never be defined inside an "if" statement. Your "GetSQLValueString" is in an "if" statement. Move the function outside of it and get rid of the "if". If you don't know that the "function_exists" you have made a mistake in your code. "function_exists" does have a use, but that is not how it was intended to be used.

    Also your code is checking if the PHP version is less than 6, all PHP versions currently in use are less that version 6 so that is an unnecessary check. Version 6 is not even scheduled for release so it is likely a very long ways down the road before it is released, and even then your server may not update to it for quite some time after its release. And really when working with PHP you should know what version you have running on your server. I know some third party libraries may do a version check so their code works with old version but if your writing your own code you don't need it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center