You can also use XML to access your MySQL data :
Basically you would have a php file on your server like this one (named getuser.php) where you establish a connection to your database, submit a query and echo the result in whatever format you require (in this case a html formatted table).
=================================================================
/* Database config */
$db_host = '....';
$db_user = '....';
$db_pass = '....';
$db_database = 'symphony_kvc';
/* End config */
$q = intval($_GET['q']);
$con = mysqli_connect($db_host,$db_user,$db_pass,$db_database);
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"$db_database");
$sql="SELECT * FROM comments WHERE id = '".$q."'";
$result = mysqli_query($con,$sql);
echo "<table border='1'>
<tr>
<th>name</th>
<th>url</th>
<th>email</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['url'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
=================================================================
The SMS code looks like this
unit Form1;
interface
uses
w3system, w3graphics, w3components, w3forms, w3fonts, w3borders,
w3application, W3Elements, W3Button, w3memo, w3editbox, w3time, W3Label, W3Image;
type
TForm1=class(TW3form)
private
{ Private methods }
{$I 'Form1:intf'}
protected
{ Protected methods }
procedure InitializeObject; override;
procedure ShowClicked(Sender: TObject);
procedure FinalizeObject; override;
procedure StyleTagObject; reintroduce; virtual;
procedure Resize; override;
procedure GetMyData;
Procedure HandleUpdate(Sender:TObject);
MyData: String;
Memo1: TW3Memo;
Button1 :TW3Button;
Edit1: TW3EditBox;
FTimer: TW3Timer;
end;
implementation
{ TForm1}
procedure TForm1.GetMyData;
begin
asm
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
@MyData = '';
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
@MyData = xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q=1",true);
xmlhttp.send();
end; //asm
end;
procedure TForm1.HandleUpdate(Sender:TObject);
begin
If MyData <> '' then begin // populate controls soon as data received
txtHint.InnerHTML := MyData;
Memo1.Text := MyData;
Button1.InnerHTML := MyData;
Edit1.Text := StrAfter(MyData,'mailto:');
FTimer.Enabled:=False;
W3Image1.Visible := false;
end;
end;
procedure TForm1.ShowClicked(Sender: TObject);
begin
W3Image1.Visible := true; //make spinner visible
GetMyData;
FTimer.OnTime:=HandleUpdate; //wait until data fetched
FTimer.Delay:=5;
end;
procedure TForm1.InitializeObject;
begin
inherited;
{$I 'Form1:impl'}
W3Image1.LoadFromURL('res/spinner.gif'); //load spinner and set to invisible
W3Image1.OnLoad :=
procedure (Sender: TObject)
begin
W3Image1.Visible := false;
end;
//create the 3 controls
Edit1 := TW3EditBox.Create(Self);
Edit1.SetBounds(30, 90, 400, 50);
W3Label1.SetBounds(30, 50, 400, 50); // title edit1
Memo1 := TW3Memo.Create(Self);
Memo1.SetBounds(30, 180, 400, 150);
W3Label2.SetBounds(30, 142, 400, 50); // title memo1
Button1 := TW3Button.Create(Self);
Button1.SetBounds(30, 520, 400, 150);
W3Label3.SetBounds(30, 330, 500, 50); // title divhtmlelement
txtHint.SetBounds(30, 370, 400, 150);
W3Button1.OnClick := ShowClicked;
FTimer:=TW3Timer.Create;
end;
The above will display a button on a form, the other element on the form being a TW3DIVHtmlElement, a Memo and an EditBox.
When clicked, the data will be fetched
Kudos w3schools, demo adapted from one of their articles
This works ok. See demo on www.lynkit.com.au/MySQL