spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / php / beginning / chap16 / 3 current pageTo page 2To page 3To page 4
[next]

Beginning PHP4

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Building a Framework

Before we can start writing the actual scripts we need to create a framework for them to work in. We are going to use a frameset of two frames alongside one another. The left-hand frame is a sidebar, while the right-hand frame will be where all of our scripts run. Here is index.html:

<HEAD><TITLE>Our Interactive Mall</TITLE></HEAD>
<FRAMESET COLS="170,*">
   <FRAME NAME="sidebar" SRC="menu.html" FRAMEBORDER="No" BORDER=0 NORESIZE>
   <FRAME NAME="mall" SRC="blank.html" FRAMEBORDER="No" BORDER=0 NORESIZE>
</FRAMESET>

To begin with, the right-hand frame will be blank, so here is blank.html:

and menu.html, our sidebar:

<HTML>
<BODY>
<para>Enter an item to search for...</para>
<FORM NAME="search" ACTION="mall.php" TARGET="mall">
<INPUT TYPE="text" NAME="criteria" SIZE="20">
<BR>
<INPUT TYPE="submit" VALUE="Search">
</INPUT></BR></INPUT></FORM>
</BODY>
</HTML>

Our form has an action of mall.php and a text box called criteria. The target of the form is the right-hand frame, in which we want our results displayed. Here's the script that will do that job:

<?php
//mall.php
include "./common_db.inc";



if ($criteria!="") {
   $link_id = db_connect('mapping');
   $query = "SELECT m_name FROM mall WHERE m_desc LIKE '%".$criteria."%'";
   $mallResult = mysql_query($query, $link_id);

   if (mysql_num_rows($mallResult) > 0) {
      while ($mallRow = mysql_fetch_array($mallResult)) {
         echo $mallRow[0]."<BR>";
      }
   }
}
?>

Fire up the index.html file we created earlier, enter shoes in the text box and click on Submit. You should see the following results:

1

Contents

home / programming / php / beginning / chap16 / 3 current pageTo page 2To page 3To page 4
[next]

Copyright 1999 Wrox Press Ltd. and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Created: March 28, 2001
Revised: March 28, 2001


URL: http://webreference.com/programming/php/beginning/chap16/3/