Hmmm .. never really tried tables much, but that could be interesting on PDAs: i'll give that a try.. I haven't really done much with PDAs up until now as I have simply used your trick of specifying a table width and using standard HTML. However, the thought of being able to use common code for mobile and PDA appeals to me a lot. I am thinking of taking the easy way out and just using a PDA browser that supports WML
As regards some sample code:
This one is a simple pick list that just demonstrates how you can generate a list of items and eventually pass the selected values to another page. I use php for the WAP header, although this could be hard coded in "WML". It also demonstrates how to pass a variable using
postfield.
Code:
<?php
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
. " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
?>
<wml>
<card id="card1" title="Shopping">
<p>
<do type="accept">
<go href="wap.php" method="post">
<postfield name="items" value="$Items"/>
</go>
</do>
Shoppinglist:<br/>
<select name="Items" multiple="true">
<option value="1">Beer</option>
<option value="2">Curry</option>
<option value="3">Veg</option>
<option value="4">Milk</option>
<option value="5">Tuna fish</option>
<option value="6">Salad</option>
<option value="7">Meat</option>
<option value="8">Cat Food</option>
</select>
</p>
</card>
</wml>
This is a handy one if you want to let people call your mobile from a WAP page

It also incorporates a bitmap graphic. You'll see quite a few headers at the top (courtesy of PHP) - this is a desperate attempt to stop the phone browser using it's cache. I found this was a
big problem especially with database work..
Code:
<?php
header("Content-type: text/vnd.wap.wml");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
. " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
echo "\n\n";
?>
<wml>
<head>
<meta http-equiv="Cache-Control" content="must-revalidate" forua="true"/>
<meta http-equiv="Cache-Control" content="max-age=0" forua="true"/>
</head>
<template>
<do type="prev" label="Previous">
<prev/>
</do>
</template>
<card id="card1" title="Call me">
<p>
<img src="dearfriend.wbmp" alt="[Our Logo]"/>
<br/>
<anchor>Call Me
<go href="wtai://wp/mc;insert-your-mobile-number-here"/>
</anchor>
<br/>
</p>
</card>
</wml>
And this one is a bit longer, but it shows database connection (uses MySQL), creating an SQL query and displaying the result. I chopped the title down to 20 characters and uses PHP's
htmlentities feature to stop the phone barfing on any "reserved" characters in the review string that it retrieves.
Code:
<?php
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
. " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
?>
<wml>
<head><meta http-equiv="Cache-Control" content="max-age=1"/></head>
<template>
<do type="prev" label="Previous">
<prev/>
</do>
</template>
<card id="card0" title="My DB Lookup">
<p>
<?php
if ( $DBcon = mysql_connect("localhost", "username","password") )
{
mysql_select_db("products");
$query = "select Title, Review from Reviews where Pno = '123456'";
$result = mysql_query($query);
if ( mysql_num_rows($result) )
{
$row = mysql_fetch_array($result);
$RV = $row[Review];
$TI = $row[Title];
echo "<small>";
echo substr($TI, 0, 20) . "...";
echo "</small>";
echo "<br/>";
echo htmlentities($RV);
echo "<br/>";
echo "<anchor>Main";
echo "<go href=\"index.wml\"/>";
echo "</anchor>";
}
else
{
echo "Sorry - we are unable to find the review for this product.";
}
mysql_close($DBcon);
}
else
{
echo "Sorry - we have a database problem right now";
}
?>
</p>
</card>
</wml>
Have fun, and keep in touch !