Title: How do I develop the PHP code to handle the request from Delphi
I'm assuming you know PHP. If you don't then you will need to get hold of a suitable tutorial. There's a good one on www.php.net
PHP can look a bit cryptic especially if you've not been exposed to a 'C' type language before. It also looks a lot like HTML - which essentially it is.
This is really simple standard PHP code. It checks that the parameters are valid, connects to the server, connects to the database and then issues a query to get the required rows from the table. For each row on the table it generates a paragraph tag, name and a closing paragraph tag.
Obviously the user name and password need to be changed to work for your particular MySQL database.
CODE
Todays Birthdays
The following have a birthday today
day not specified");
}
if (!isset($_GET['month'])) {
die("month not specified");
}
$day = $_GET['day'];
$month = $_GET['month'];
$cnx = mysql_connect('localhost','root','password');
if (!$cnx) {
die('Unable to connect to database server');
}
if (!@mysql_select_db('birthsdb') ) {
die('Unable to connect to birthsdb database');
}
$select = "SELECT name FROM birthdays WHERE MONTH(born)=$month AND DAYOFMONTH(born)=$day";
$result = @mysql_query($select);
if (!$result) {
die("Unable to process: $select");
}
while ( $row = mysql_fetch_array ($result) ) {
echo("\n\n" . $row['name'] . "\n");
}
?
}
To make life simple for the Delphi program that is going to read the HTML I've coded the , birthday name and the on different lines. The output will look something like:
Beatrix Potter