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
Mozilla's Ubquity Mashup: For The Masses?
iPhone Users Just Want to Have Fun
Oops! I Fixed the Linux Kernel

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

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Performance Optimizations for High Speed JavaScript · Advanced Web Performance Optimization · Simple Comments Meets OpenID
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Extending Telephony: VoIP Call Recording for Business · U-Verse for Business Has Wi-Fi Perks · Lian-Li Launches New Power Supply Line, Rack Mount Kit and Fan Blower


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


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