Displaying records 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 ="conrecords" Server Name =
"localhost" User Name = "root" Password =
"" Database Name = "a-bible_en'" |
|
Database Name =
"a-bible_en'" 1-Table Name = "biblenewtable" |
| |
| |
|
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.
- 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.
- Open a web browser such as Firefox or Internet Explorer.
- In the Address bar, enter http://localhost.
You should see a
XAMPP splash screen with language options.
- 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 Displaying records Folder: 1-
index+navigation.php - php files + ... |
|
|
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 |
|
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\records-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:
records-site local Site Folder: C:\xampp\htdocs\records-site |
|
|
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:
records-site connect
using:
Local/Network Server
Folder:
C:\xampp\htdocs\records-site Web
URL:
http://localhost/records-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: records-site |
|
then click Done |
Setup the site's Testing Server and then click
OK |
|
|
|
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_en.sql file from
...\\15-Course, Displaying records site, PHP-MYSQL\Displaying records
Folder to folder
C:\xampp\htdocs\records-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\records-site\a-bible_en.sql) to create the a-bible_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_en.sql file that you downloaded, and click the Go button to have the database created: |
|
|
Message about a-Bible_en.sql display: Import has been
succcessully ... |
|
|
the Database
"a-bible_en" stores 1
table: biblenewtable
On the Structure tab, to be Displays: the Table
"biblenewtable" of Database "a-bible_en" |
|
|
|
index+navigation.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 |
Go to File -> New. In the File Creation dialog, select Blank Page.
From the page type section, select PHP and click the
create. |
|
|
Go to File -> Save. In the Save As option, enter "index+navigation.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:
conrecords MySQL
server:
localhost User
name:
root Password:
Database: a-bible_en |
when click Select Button, to be
display Select Database box, select a-bible_en and then click
Ok |
|
4) Click the test button then Click OK |
|
5) Click OK |
|
Step 5: list of Navigation
Operations |
1- Go To Text,
Read
Detail info about this, Navigating database recordset |
2- Recordset navigation links require the
following dynamic elements:
-
A recordset to navigate
-
Dynamic content on the page to display
the record or records
-
Text or images on the page to serve as a
clickable navigation bar
-
A Move To Record set of server behaviors
to navigate the recordset
|
3- list of Operations ..., Insert > Data Objects >
.... |
|
|
View of Recordset created,
Using Insert > Data Objects > Recordset , Dialog Box |
|
|
4- list of Operations
corresponding to create this page - index+navigation.php |
|
|
Step 6: The Designs and
Codes of ... |
1nd Group of operation consists of the main
file - index+navigation.php and the part files - Connections/conrecords.php of the main |
|
A- the Design and Code of
index+navigation.php 1st Group of operation
consists of the main file - index+navigation.php |
1- The Design of
index+navigation.php |
|
|
2- The Code of
index+navigation.php |
<?php require_once('Connections/conrecords.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;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 1;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_conrecords, $conrecords);
$query_Recordset1 = "SELECT * FROM biblenewtable";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d",
$query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $conrecords) or
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 =
ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s",
$totalRows_Recordset1, $queryString_Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Navigation</title>
<style type="text/css">
.chktext {
max-width:600px;
max-height:100px;
min-width:600px;
min-height:100px;
font-size:14px;
font-family:"Times New Roman", Times, serif;
}
.chkcolor {
color: #333333;
background-color: #E1E1E1;
font-family: "Times New Roman", Times, serif;
font-size: 12px;
}
</style>
</head>
<body>
<table width="90%" border="0" cellspacing="2" cellpadding="2"
align="center">
<tr>
<th scope="col" 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;" align="center"
>Navigating database recordset </th>
</tr>
<tr>
<td align="center"><table width="100%" border="0" cellspacing="2"
cellpadding="2">
<tr>
<th scope="col" width="60%" align="center">
<table width="80%" border="1" cellspacing="2" cellpadding="2">
<tr>
<th scope="col" style="background-color: #8090AB;" > </th>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<th scope="col" width="5%"> </th>
<th scope="col" width="15%" align="right" class="chkcolor">Book:</th>
<th scope="col" width="25%"><div align="left">
<input name="firstname" id="firstnameid" tabindex="1" value="<?php
echo $row_Recordset1['Book']; ?>" size="25" maxlength="300" />
</div></th>
<th scope="col" width="10%"> </th>
<th scope="col" width="15%" align="right" class="chkcolor">Chapter:</th>
<th scope="col" width="25%"><div align="left">
<input name="firstnameid2" id="firstnameid3" tabindex="1" value="<?php
echo $row_Recordset1['Chapter']; ?>" size="25" maxlength="300" />
</div></th>
<th scope="col" width="5%"> </th>
</tr>
<tr>
<td width="5%"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td width="5%"> </td>
</tr>
<tr>
<td width="5%"> </td>
<td width="15%" align="right" class="chkcolor">Title:</td>
<td width="25%"><div align="left">
<input name="firstnameid" id="firstnameid2" tabindex="1" value="<?php
echo $row_Recordset1['BookTitle']; ?>" size="25" maxlength="300" />
</div></td>
<td width="10%"> </td>
<td width="15%" align="right" class="chkcolor">Verse:</td>
<td width="25%"><div align="left">
<input name="firstnameid3" id="firstnameid4" tabindex="1" value="<?php
echo $row_Recordset1['Verse']; ?>" size="25" maxlength="300" />
</div></td>
<td width="5%"> </td>
</tr>
</table></td>
</tr>
<tr>
<td align="center"><textarea name="textdata" class="chktext" id="experienceid"
tabindex="15"><?php echo $row_Recordset1['TextData']; ?></textarea></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<th width="10%" align="center" class="chkcolor" scope="col"> <?php if
($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0,
$queryString_Recordset1); ?>">First</a>
<?php } // Show if not first page ?> </th>
<th scope="col" width="10%" align="center" class="chkcolor"> <?php if
($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage,
max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>"
>Previous</a>
<?php } // Show if not first page ?> </th>
<th scope="col" width="10%" align="center" class="chkcolor"> <?php if
($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last
page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage,
min($totalPages_Recordset1, $pageNum_Recordset1 + 1),
$queryString_Recordset1); ?>">Next</a>
<?php } // Show if not last page ?> </th>
<th scope="col" width="10%" align="center" class="chkcolor"> <?php if
($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last
page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage,
$totalPages_Recordset1, $queryString_Recordset1); ?>">Last</a>
<?php } // Show if not last page ?> </th>
<th width="55%" align="center" scope="col"><table width="80%"
border="0" cellspacing="2" cellpadding="2">
<tr>
<th scope="col" width="5%"> </th>
<th scope="col" width="30%" align="center" class="chkcolor"> <?php
echo ($startRow_Recordset1 + 1) ?></th>
<th scope="col"width="20" align="center" class="chkcolor"> of
</th>
<th scope="col"width="30%" align="center" class="chkcolor"> <?php
echo $totalRows_Recordset1 ?> </th>
<th scope="col"width="5%"> </th>
</tr>
</table></th>
</tr>
</table></td>
</tr>
<tr>
<td style="background-color: #8090AB;" > </td>
</tr>
</table></th>
<th scope="col" width="40%" align="center" style="background-color:
#8090AB;"><table width="400" border="0" align="center" cellpadding="2"
cellspacing="2">
<tr>
<th scope="col" align="center" width="100%"w ><img src="images/contactusimage.jpg"
width="231" height="356" longdesc="images/contactusimage.jpg" /></th>
</tr>
</table></th>
</tr>
</table></td>
</tr>
<tr>
<td align="center"><a href="www.puresoftwarecode.com">@ pure software
code</a></td>
</tr>
<tr>
<td style="background-color: #8090AB;"> </td>
</tr>
<tr>
<td > </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?> | |
|
3- the
Code, conrecords.php page File |
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conrecords = "localhost";
$database_conrecords = "a-bible_en";
$username_conrecords = "root";
$password_conrecords = "";
$conrecords = mysql_pconnect($hostname_conrecords, $username_conrecords,
$password_conrecords) or trigger_error(mysql_error(),E_USER_ERROR);
?> | |
|
|
|
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+navigation.php |
|
|
|
|
|