|
|
|
// Chart Search version 1
//
// Peter T Garner.
// Uses PHP and MySQL.
// This works fine on my Mitsubishi Trium. YMMV.
// I developed this on the Linux version of the
// deckit emulator from www.pyweb.com.
//
// This is the first deck that prompts you for
// a chart (table), then a (book) Isbn to search for.
//
// N.B ******************
// The decks detailed below serve to illustrate
// how WML can be combined with PHP and MySQL to
// enable WAP-enabled devices to select and display
// data from a multi-table database. I used book chart
// data from my employer, Whitaker BookTrack (see
// http://www.booktrack.co.uk) as part of a pilot project.
// Currently, there is no WAP based service from Whitaker
// BookTrack, but this may change in the near future. Please
// contact me at peterg@teleord.co.uk for more information.
<?php
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\" ?>";
?>
<!DOCTYPE wml PUBLIC "-//PHONE.COM//DTD WML 1.1//EN"
"http://www.phone.com/dtd/wml11.dtd" >
<wml>
<template>
<do type="prev" label="Previous">
<prev/>
</do>
</template>
<card id="card0" ontimer="#card1">
<timer name="key" value="30"/>
<p align="center">
<strong><big>ChartSearch..</big></strong>
<br/>
from <strong><big>BookTrack</big></strong>
<br/>
<small>
<i>
For Charts on the Move !
</i>
</small>
</p>
</card>
<!-- chart select -->
<card id="card1" title="Selector">
<p>
Please select a chart from the list:<br/>
<?php
if ( $DBcon = mysql_connect("localhost", "","") )
{
$result = mysql_list_tables("chart");
$i = 0;
echo "<select name=\"myChart\">";
while ($i < mysql_num_rows ($result) )
{
$tn[$i] = mysql_tablename ($result, $i);
echo "<option value=\"$tn[$i]\">$tn[$i]";
echo "</option>";
$i++;
}
echo "</select>";
}
mysql_close($DBcon);
?>
<do type="accept" label="Proceed">
<go href="#card2" method="post">
</go>
</do>
</p>
</card>
<!-- enter search data -->
<!-- We only want digits 1-9 of the Isbn as it will be
unique in the database without the check digit. If
we assume a match for the Isbn, the check digit will
be added when the result is returned.
Note the 2 postfield statements that will pass on the 2
variables that we collect on the way. We need to post
them now as we are going to leave this deck after we
enter the ISBN -->
<card id="card2" title="Search">
<p>
<do type="accept" label="Search">
<go href="c2b.wml" method="post">
<postfield name="Isbn" value="$Isbn"/>
<postfield name="myChart" value="$myChart" />
</go>
</do>
Enter Isbn:<br/>
<input title="Isbn" name="Isbn" size="9" maxlength="9" format="NNNNNNNNN"/>
</p>
</card>
</wml>
// Once you have selected your database table and entered
// your search string, this deck is then accessed (c2b.wml).
// It uses a simple MySQL database called "Charts" and the
// tables are named according to the week they relate to.
// Please note that this script doesn't do any checking for
// length of output. If it's over the limit you will probably
// get a 'malformed http' message or something similar. This
// will be tidied up in the next version..
<?php
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\" ?>";
?>
<!DOCTYPE wml PUBLIC "-//PHONE.COM//DTD WML 1.1//EN"
"http://www.phone.com/dtd/wml11.dtd" >
<wml>
<template>
<do type="prev" label="Go Back">
<prev/>
</do>
</template>
<card id="card2" title="Result">
<p>
<?php
if ( !empty($Isbn) )
{
if ( $DBcon = mysql_connect("localhost", "","") )
{
mysql_select_db("chart");
$query = "select ISBN, cPosition, Author, Title, ";
$query .= " RRP, ASP, WeeksIn, PrevPos, Imprint from ";
$query .= $myChart;
$query .= " where ISBN like '$Isbn%'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
if ( $row )
{
//
// we need to change any ampersands to '+'
//
$TI = strtr($row[Title], "&", "+");
$AU = strtr($row[Author], "&", "+");
//
// sometimes, an author is not listed on the database
//
if ( empty($row[Author])) { $AU = "unknown"; }
//
// we need to change any ampersands to '+'
//
$AU = explode (",", $AU);
$PU = strtr($row[Imprint], "&", "+");
//
// now we will display our result.. We swap the first
// and last names of the author to produce a user-friendly
// display.
//
echo "Isbn $row[ISBN] is '$TI' by '$AU[1] $AU[0]' with an ";
echo "RRP of #$row[RRP]. ";
echo "Currently it is at number $row[cPosition]. ";
//
// A more user-friendly display of new entries..
//
if ( $row[WeeksIn] == '0' )
{
echo "This is a new entry in the charts. ";
}
else
{
echo "It has been in the charts for ";
echo "$row[WeeksIn] ";
echo "weeks. ";
echo "Last week it was at number ";
echo "$row[PrevPos]. ";
}
// Say who publishes it ..
echo "It is published by $PU. ";
echo "The typical street price is #$row[ASP]";
//
// And show a disclaimer along with the tablename
// that we used..
//
echo "<br/><br/><small>(C) BookTrack " . date('Y') . "<br/>E&OE</small>";
echo "<br/><small>$myChart</small>";
}
else
{
echo "Sorry<br/>No match for $Isbn";
}
mysql_close($DBcon);
}
}
else
{
echo "You can't have an empty ISBN";
}
?>
<br/>
</p>
</card>
</wml>
|
|
| WML error handler for the Apache webserver. Categories : PHP, WML, WAP | | | wap device's headers on-line on wap phone Categories : WAP, WML, PHP | | | Simple phone list search for your WAP device. Uses PHP and MySQL. Also lets you dial out to your entries using wtai://wp/mc if your phone supports it. No WMLscript. Categories : PHP, MySQL, WAP | | | php embeded with wml ,wmlscript ,simple example U can add mysql Categories : WAP, PHP, WML | | | bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | | | Sample WML Mailer Categories : PHP, WAP, WML, Email | | | Cut your MySQL Connections to 1 line of code Categories : PHP, Beginner Guides, Databases, MySQL | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | | | phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | Displaying records of database in more than one page (paging) Categories : Databases, MySQL, PHP | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Retrieve text from table and email to your e-
address in pipe delimited format. Categories : PHP, MySQL | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | Tropicalm Genetree Family (MySQL based family tree) Categories : PHP, Interfaces, Databases, MySQL, Complete Programs | |
|
|
|