Freelance Web Designer East Sussex
Link Exchange System with Dreamweaver CS3, PHP, MySQL and CSS Part 3
All my tutorials are completely free of charge. If you found them useful and would like to make a donation towards the new tutorials, please click the button below.
<<Display Search Result | Submit link page>>
Latest Links Page
This chapter will explain how to create a page which will display the latest links.
Open links_search_result.php and select the content starting from the line which reads:
<?php require_once('../Connections/conndb.php'); ?>
down to (including) the line which reads:
$queryString_rsLinks = sprintf("&totalRows_rsLinks=%d%s", $totalRows_rsLinks, $queryString_rsLinks); ?>
Copy and paste it at the top of the links_latest.php page, before <!DOCTYPE.
Now identify the line which reads:
<?php include ('../includes/search_engine.php'); ?>
Place your cursor at the end of this line and hit Enter on your keyboard to create a new line. Go back to links_search_result.php and copy the content from within the body tag starting with:
<p id="title"><?php if (isset($categ) && $categ != "") { echo $row_rsLinks['catname']; } else { ?>Search result<?php } ?></p>
and ending with (including):
<?php } // Show if recordset empty ?>
Go to links_latest.php and paste it on the newly created line. Go again to links_search_result.php, copy the following:
<?php mysql_free_result($rsLinks); ?>
and paste it in links_latest.php right at the end of the document, after closing </html> tag.
Now we will need to change a few things to make this page display the latest links. First of all identify this chunk of code:
if (isset($_GET['catid']) && $_GET['catid'] != "") {
$categ = $_GET['catid'];
$query_rsLinks = "SELECT tbl_links.linktitle, tbl_links.linkurl, tbl_links.linkdescr, tbl_categories.catname FROM tbl_links, tbl_categories WHERE tbl_links.linkcat=tbl_categories.catid AND tbl_links.linkapproved='y' AND tbl_links.linkcat = $categ ORDER BY tbl_links.linkdate ASC";
} else if (isset($_GET['keyword'])) {
$keyword = $_GET['keyword'];
$query_rsLinks = "SELECT tbl_links.linktitle, tbl_links.linkurl, tbl_links.linkdescr, tbl_categories.catname FROM tbl_links, tbl_categories WHERE tbl_links.linkcat=tbl_categories.catid AND tbl_links.linkapproved='y' AND (tbl_links.linkurl LIKE '%$keyword%' OR tbl_links.linktitle LIKE '%$keyword%' OR tbl_links.linkdescr LIKE '%$keyword%') ORDER BY tbl_links.linkdate ASC";
} else {
$query_rsLinks = "SELECT linktitle, linkurl, linkdescr, tbl_categories.catname FROM tbl_links, tbl_categories WHERE linkapproved = 'y' AND tbl_links.linkcat = tbl_categories.catid ORDER BY linkdate ASC";
}
and replace it with the following:
$query_rsLinks = "SELECT linktitle, linkurl, linkdescr, tbl_categories.catname FROM tbl_links, tbl_categories WHERE linkapproved = 'y' AND tbl_links.linkcat = tbl_categories.catid ORDER BY linkdate DESC";
Identify the line which reads:
<p id="title"><?php if (isset($categ) && $categ != "") { echo $row_rsLinks['catname']; } else { ?>Search result<?php } ?></p>
and replace it with:
<p id="title">Latest links</p>
And that′s it there is to it.
Our Latest links page is done.
In the next chapter I′ll explain how to create our last page - links_submit.php.
<<Display Search Result | Submit link page>>
Website Design Company | Small Business Web Site Design | Ecommerce Web Site Design | Web Design Tutorials
UK Content Management System | Database Design | Flash Animation | Web Designer Resources | Independent Web Hosting Review
Illustrator Tutorial | Web Design Tutorials | Chichester Restaurants
© Freelance Web Designer - Sebastian Sulinski | Valid CSS | Valid XHTML