Pagination site, PHP-MYSQL Course
              In the steps of this tutorial, I will be using the XAMPP server  for Windows ...     Mars 2015     
 General Info:
 
 Connection Name ="conbiblenew2"
 Server Name = "localhost"
 User Name = "root"
 Password = ""
 Database Name = "a-Bible-new2-en"
 
  Database Name = "a-Bible-new2-en"
  1-Table Name = "bibletablenew2"
 
        The Steps to Create the Pagination in the database ...
  1. The Testing Server
  2. Defining a Dreamweaver Site
  3. Create A Database
  4. index-pagination.php page File
     
  5. Show or Preview Display the page sites, of ...
 
 
Pagination
pages site
 
 
 
 
Developed with
PHP
 
 
 

The Testing Server        

If you wish to install a local testing server, you can download the XAMPP package for Windows http://www.apachefriends.org/en/xampp.html

Once XAMPP is a completely installed. XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl.
 
You can use the XAMPP Control Panel to start your testing server.

  1. Click Start next to both Apache and MySQL to start the services.
    Starting these services can take a few seconds. When it is complete, 'Running' will display beside each option.
 
To make your testing server start automatically when your computer starts, you can check the Svc checkbox beside both options.
If the XAMPP Control Panel is not already running, go to C:\xampp\control.exe to open the panel.

1- XAMPP Control Panel
 

With your testing server now installed and running, there are a few final steps you should take to make sure everything is configured to work perfectly.

  1. Open a web browser such as Firefox or Internet Explorer.
  2. In the Address bar, enter http://localhost.
    You should see a XAMPP splash screen with language options.
  3. Choose your preferred language.
    You should now see a confirmation window informing you that 'You have successfully installed XAMPP on your system'
 
 2- List of Files

the php + sql  files and Folders corresponding, stored at Pagination Folder - (...\\17-Course,  Pagination site, PHP-MYSQL\Pagination Folder):
the main File - index-pagination.php
 
Defining a Dreamweaver Site
Once a testing server is set up, either locally or using a remote hosting service, you will need to define a site for Dynamic Development in Dreamweaver
 

Step 1: Start the site definition

In Dreamweaver go to Site -> New Site.

Note: you can edit an existing site definition by going to Site -> Manage Sites. Select the site you wish to modify, then click the edit button.

 

Step 2: Enter the local Information

In the first section of the site definition, you will set the Local Information. This sets the Site Name, and local path for files in your site.

When using XAMPP in a windows system, it may be that the site root is mapped to:
C:\xampp\htdocs
so the new site folder would be created under that location: C:\xampp\htdocs\pagination-site

In this screen shot, using DW CS6 on a Windows system with XAMPP installed. you will set the Local Information. This sets the Site Name, and local path for files in your site.
Site Name:           pagination-site
local Site Folder: C:\xampp\htdocs\pagination-site

 

Step 3: Servers

The next setting is to connect to servers. In DW CS6 and above, this done by selecting the servers section:

 
and clicking the plus icon to define a new server connection.
at Basic tab, For the Name you can enter the same name as the Site definition, When using a local testing server, set Connect Using to "Local/Network"
Set the Server Folder to the same location as the local files set in the initial Site Settings.
Server Name:           pagination-site
connect using:             Local/Network
Server Folder:          C:\xampp\htdocs\pagination-site

Web URL:                http://localhost/pagination-site
 
at Advanced tab,
Click the advanced button and set the Application model to PHP / MySQL
Server Model:  PHP MySQL 
then click Save.
Once the connection is defined, there are check boxes to set the connection as a testing or remote connection, check the testing option.
and then Click Save, the Dreamweaver dialog box display:
 
Step 4: Manage Sites
you can edit an existing site definition by going to Site -> Manage Sites. Your Sites: pagination-site
then click Done
Setup the site's Testing Server and then click OK
 
Create A Database
n this section, we'll look into how to create a database. A database is used to store information for your site.
Copy a-Bible-new2-en.sql file  from ...\\17-Course,  Pagination site, PHP-MYSQL\Pagination Folder  to folder C:\xampp\htdocs\pagination-site
Most web hosts use a control panel for managing your site, in the control panel they will have a way to create a MySQL Database. Once a database has been created, you can use phpMyAdmin to edit it.
phpMyAdmin is also available using most Local Testing server packages like XAMPP. The Start pages for those server will have a link to open phpMyAdmin.

In phpMyAdmin, go to the Import tab. Use this .sql script (C:\xampp\htdocs\pagination-site\a-Bible-new2-en.sql) to create the a-Bible-new2-en database that we will be using :.



Step 1: import SQL file
On the import tab, Click the chose file button, and select the a-Bible-new2-en.sql file that you downloaded, and click the Go button to have the database created:
 
 
Message about a-Bible-new2-en.sql display: Import has been succcessully ... 
 
the Database "a-Bible-new2-en" stores 1 table: bibletablenew2
On the Structure tab, to be Displays:  the Table "bibletablenew2" of Database "a-Bible-new2-en"
 

 
index-pagination.php page File
 
Now that a site and a database are created, lets connect the 2 together.

Before creating the database connection, a new PHP file needs to be created and saved to the site

Step 1: Create a New PHP page

Go to File -> New. In the File Creation dialog, select Blank Page. From the page type section, select PHP and click the create.

 

Step 2: Save the page to your site

Go to File -> Save.
In the Save As option, enter "index-pagination.php"

In the Where section, select the folder for your site.

 
Step 3: the Site has been defined
- testing server
-
Once the site has been defined, at Dreamweaver - Dw display current Message: "This page may have dynamically-related files that can only be discovered by the server. Discover | Preferences.
 
Step 4: Create the connection to the database
1) open the database panel by going to Window -> Database.

2) In the database panel, click the plus button and select MySQL Connection

3) enter the:
connection name:        conbiblenew2
MySQL server:          localhost
User name:                 root
Password:                                                 

Database:                  a-Bible-new2-en
when click Select Button, to be display Select Database box, select a-Bible-new2-en and then click Ok
4) Click the test button then Click OK
5) Click OK
 
Step 5: The Designs and Codes of ...
1nd Group of  operation consists of the main file - index-pagination.php and the part files - config.php, paginate.php and css\style.css  of the main
 
A- the Design and Code of index-pagination.php
 
1st Group of  operation consists of the main file - index-pagination.php
 1- The Design of index-pagination.php
 
2- The Code of index-pagination.php
<?php

include('config.php'); //include of db config file
include ('paginate.php'); //include of paginat page

$page=1;
$show_page=1;
$per_page = 5; // number of results to show per page
$result = mysql_query("SELECT * FROM bibletablenew2");
$total_results = mysql_num_rows($result);
$total_pages = ceil($total_results / $per_page);//total pages we going to have

//-------------if page is setcheck------------------//
if (isset($_GET['page'])) {
$show_page = $_GET['page']; //it will telles the current page
if ($show_page > 0 && $show_page <= $total_pages) {
$start = ($show_page - 1) * $per_page;
$end = $start + $per_page;

// display pagination
$page = intval($_GET['page']);
} else {
// error - show first set of results
$start = 0;
$end = $per_page;
$page =0;
}
} else {
// if page isn't set, show first set of results
$start = 0;

$end = $per_page;
$page =1;
}


$tpages=$total_pages;
if ($page <= 0)
$page = 1;



?>




<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pagination</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<style type="text/css">
.logo
{
text-align: center;
}
.container{

}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="logo">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<th scope="col" height="8px"></th>
<tr>
<td><table width="100%" border="3" cellspacing="0" cellpadding="0" bordercolor="#8090AB;">
<tr>
<th scope="col"><table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
<th scope="col" align="center" width="15%"><img src="img/logo-tech.jpg" longdesc="img/logo-tech.jpg"></th>
<th scope="col" align="center" width="75%" height="80px" style="background-color: #8090AB; font-size: xx-large; color: #FFF; font-family: 'Times New Roman', Times, serif; font-weight: bold; font-style: italic;" >Pagination database ...</th>
</tr>
</table></th>
</tr>
</table>

</td>
</tr>
</tr>
<tr>
<td align="left" height="10px"></td>
</tr>

<tr>
<td align="center" height="375px">
<?php
// display data in table
echo "<table class='table table-bordered'>";
echo "<thead><tr><th>Book Title</th> <th>Chapter</th> <th>Verse</th> <th>Text Data</th> </tr></thead>";

// loop through results of database query, displaying them in the table
for ($i = $start; $i < $end; $i++) {
// make sure that PHP doesn't try to show results that don't exist
if ($i == $total_results) {
break;
}

// echo out the contents of each row into a table

echo '<td>' . mysql_result($result, $i, 'BookTitle') . '</td>';
echo '<td>' . mysql_result($result, $i, 'Chapter') . '</td>';
echo '<td>' . mysql_result($result, $i, 'Verse') . '</td>';
echo '<td>' . mysql_result($result, $i, 'TextData') . '</td>';

echo "</tr>";
}

// close table>
echo "</table>";
// pagination
?>
</td>
</tr>

<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<th scope="col" width="60%" align="center"><table width="84%" border="0" cellspacing="1" cellpadding="1">
<tr>
<th scope="col" align="center">
<?php
$reload = $_SERVER['PHP_SELF'] . "?tpages=" . $tpages;
echo '<div class="pagination"><ul>&nbsp;&nbsp;';
if ($total_pages > 1) {
echo paginate($reload, $show_page, $total_pages);
}
echo "</ul></div>";
?>

</th>
</tr>
</table></th>
<th scope="col" width="40%" align="center">
<?php
echo "<div>&nbsp;Page Number: &nbsp;&nbsp;&nbsp;".$page."&nbsp;&nbsp;of&nbsp;&nbsp;" .$tpages. "</div>" ;

?>
</th>
</tr>
</table></td>
</tr>
<tr>
<td align="center" height="13px"><a href="www.puresoftwarecode.com">@ pure software code</a></td>
</tr>
<tr>
<td style="background-color: #8090AB;" align="center" height="8px"></td>
</tr>
</table>
</div>
</div>

</div>
</body>
</html>
 
3-  the Code, config.php page File
<?php

$mysql_hostname = "localhost"; //your mysql host name
$mysql_user = "root"; //your mysql user name
$mysql_password = ""; //your mysql password
$mysql_database = "a-bible-new2-en"; //your mysql database

$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("some thing went wrong");
mysql_select_db($mysql_database, $bd) or die("Error on database connection");
 
4-  the Code, paginate.php page File
<?php

function paginate($reload, $page, $tpages) {

$adjacents = 2;
$prevlabel = "&lsaquo; Prev";
$nextlabel = "Next &rsaquo;";
$out = "";
// previous
if ($page == 1) {
$out.= "<span>" . $prevlabel . "</span>\n";
} elseif ($page == 2) {
$out.= "<li><a href=\"" . $reload . "\">" . $prevlabel . "</a>\n</li>";
} else {
$out.= "<li><a href=\"" . $reload . "&amp;page=" . ($page - 1) . "\">" . $prevlabel . "</a>\n</li>";
}

$pmin = ($page > $adjacents) ? ($page - $adjacents) : 1;
$pmax = ($page < ($tpages - $adjacents)) ? ($page + $adjacents) : $tpages;
for ($i = $pmin; $i <= $pmax; $i++) {
if ($i == $page) {
$out.= "<li class=\"active\"><a href=''>" . $i . "</a></li>\n";
} elseif ($i == 1) {
$out.= "<li><a href=\"" . $reload . "\">" . $i . "</a>\n</li>";
} else {
$out.= "<li><a href=\"" . $reload . "&amp;page=" . $i . "\">" . $i . "</a>\n</li>";
}
}

if ($page < ($tpages - $adjacents)) {
$out.= "<a style='font-size:11px' href=\"" . $reload . "&amp;page=" . $tpages . "\">" . $tpages . "</a>\n";
}
// next
if ($page < $tpages) {
$out.= "<li><a href=\"" . $reload . "&amp;page=" . ($page + 1) . "\">" . $nextlabel . "</a>\n</li>";
} else {
$out.= "<span style='font-size:11px'>" . $nextlabel . "</span>\n";
}
$out.= "";
return $out;
}
 
5-  the Code, css\style.css File
 

 

Show or Preview Display the page sites, of  ...

in Dreamweaver, select or open (php) files,
Go to File -> Preview in Browser -> IExplore or chrome, to Show and display the Search Operations...
1st Group of  operation - index+pagination.php
 
 
pure software code