Im having a problem with the following wml page. Im trying to access a mySQL database which has the following table and fields with a few records inserted in.
Database: ntu_doc
Table: announcements
Fields: Year, Date, Module, Message
after coding this page and trying to check it in my WAP browser, I get the following displayed in my browser
Announcements Yr1:
";// if information fitting the query is found // format and display it to the screen if (mysql_num_rows() > 0) : while ( = mysql_fetch_array()) :print "[year] [date] [module] [message]
";endwhile; // if no information fitting the query is found, // display relevant message. else:print "No current announcements.";endif;?>
The code is as follows (I have no idea whats wrong with the code, Im guessing its something minor, as this is the first time im coding im WML)
<?php
// send wml headers
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="Announcements Yr1">
<p>
<?php
// connect to mysql database
$connect = mysql_connect("localhost", "justin","justin");
// select database
$db = mysql_select_db("ntu_doc");
// select information from announcements db
$query = "select year, date, module, message from announcements";
$result = mysql_query($query);
print "<b>Announcements Yr1:</b><br/>";
// if information fitting the query is found
// format and display it to the screen
if (mysql_num_rows($result) > 0) :
while ($row = mysql_fetch_array($result)) :
print "$row[year] $row[date] $row[module] $row[message] <br/>";
endwhile;
// if no information fitting the query is found,
// display relevant message.
else:
print "No current announcements.";
endif;
?>
</p>
</card>
</wml>
I would be grateful if anyone could help me
Thanks