paging script for my code

Discussion in 'PHP' started by rakhe, Aug 14, 2009.

  1. #1
    Hello friends,

    I am making website based on SMS Messages.. I am fetching SMS from directory..I have 20 sms categories and 20 directories for each categorries,,,each directories has text files...I am fetching data froem directories... I want 10 txt files in per pages..i want paging script for that .my code is given below.Please check the website www.sms2friends.co.cc..in while loop i am opening directory and get files from directores and disply in my page now i want paging script for that.I am using this code for paging i stored contecnt in array then divide total file by 10...

    PHP Code:

    if($dir!='blank')
    {
    $dh=opendir($dir);
    while (($file = readdir($dh)) !== false)
    {
    if ($file != "." && $file != "..")
    {
    $fulfile=$dir ."/". $file;
    $subtotal[]=$fulfile;
    $total_items[] = count($subtotal);
    $pages[] = ceil($total_items /10);
    print_r ($pages);
    }
    }
    closedir($dh);
    }

    ..Please help me below the whole code i am using ...


    PHP Code:
    <?php
    $dbname = 'space_3211329_message';
    $link = mysql_connect("localhost","root","123456") or die("Couldn't make connection.");
    $db = mysql_select_db($dbname, $link) or die("Couldn't select database");
    $result = mysql_query("SELECT * FROM categories");
    while($row=mysql_fetch_array($result))
    {
    echo "<a href='index.php?app=1'>".$row['anniversary']."</a>";
    echo "<br />";
    echo "<a href='index.php?app=2'>".$row['birthday']."</a>";
    echo "<br />";
    echo "<a href='index.php?app=3'>".$row['christmas']."</a>";
    echo "<br />";
    echo "<a href='/index.php?app=4'>".$row['exam']."</a>";
    echo "<br />";
    }
    ?>
    </td>
    </tr>
    </table>
    </td>
    <td width="80%">
    <?php
    switch($_GET['app'])
    {
    case 1:
    $dir = 'anniversary';
    break;

    case 2:
    $dir = 'birthday';
    break;

    case 3:
    $dir = 'christmas';
    break;

    case 4:
    $dir = 'exam';
    break;


    default:
    $dir = 'blank';
    }

    if($dir!='blank')
    {
    $dh=opendir($dir);
    while (($file = readdir($dh)) !== false)
    {
    if ($file != "." && $file != "..")
    {
    $fulfile=$dir ."/". $file;
    $subtotal=file_get_contents($fulfile);
    echo($subtotal);
    echo "<hr/>";
    }
    }
    closedir($dh);
    }
     
    rakhe, Aug 14, 2009 IP