Hi everyone,
I'm still a newbie in B4A, yesterday I was able to run "Online Scoreboard" on my device by admac231..thanks. This morning I tried to create my own version of program...I created student_info database with one table (students) with the following fields..
id, stud_id, fname, lname, address, contact, course
Currently I'm having trouble displaying it as I needed.
My question is how can I arrange the display of the fields in this format?
1. Ben Ventura
StudID: 12345 Add: Barbara st. Course: Bscoe Tel:3215950
This is the php script I'm using
B4A code
Thank you in advance,
microbox
I'm still a newbie in B4A, yesterday I was able to run "Online Scoreboard" on my device by admac231..thanks. This morning I tried to create my own version of program...I created student_info database with one table (students) with the following fields..
id, stud_id, fname, lname, address, contact, course
Currently I'm having trouble displaying it as I needed.
My question is how can I arrange the display of the fields in this format?
1. Ben Ventura
StudID: 12345 Add: Barbara st. Course: Bscoe Tel:3215950
This is the php script I'm using
B4X:
<?php
$myPassword = "pass";
$mysqlHostName ="127.0.0.1";
$mysqlDatabaseName = "student_info";
$mysqlUsername = "root";
$mysqlPassword = "";
if($_GET['secret']!=$myPassword){
die("Access denied...student records");
}
mysql_connect($mysqlHostName, $mysqlUsername, $mysqlPassword) or die(mysql_error());
mysql_select_db( $mysqlDatabaseName) or die(mysql_error());
if(isset($_GET['id'])){
$id = $_GET['id'];
$id = mysql_real_escape_string($id);
$lname = $_GET['lname'];
$lname = mysql_real_escape_string($lname);
$fname = $_GET['fname'];
$fname = mysql_real_escape_string($fname);
}
if($id == "view"){
$result = mysql_query("SELECT * FROM students") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['lname']." ";
echo $row['fname']." ";
echo "\r\n".$row['address']."\r\n";
}
}
?>
B4X:
Sub Process_Globals
Dim httpC As HttpClient
End Sub
Sub Globals
Dim cmdViewMe As Button
cmdViewMe.Initialize("cmdViewMe")
Dim lstStudents As ListView
lstStudents.Initialize("lstStudents")
Dim httpReq As HttpRequest
Dim reader As TextReader
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
httpC.Initialize("httpC")
End If
cmdViewMe.Text = "Me"
Activity.AddView(cmdViewMe,75%x+5dip,5dip,25%x-5dip,50dip)
lstStudents.ScrollingBackgroundColor = Colors.Transparent
Activity.AddView(lstStudents,0,55dip,100%x,100%y-65dip)
End Sub
Sub cmdViewMe_Click
Dim req As HttpRequest
req.InitializeGet("http://192.168.1.101/students.php?secret=pass&id=view")
httpC.Execute(req, 2)
ProgressDialogShow("Fetching your students list...")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Activity.Finish
End Sub
Sub httpC_ResponseSuccess (Response As HttpResponse, TaskId As Int)
lstStudents.Clear
Dim result As String
result = Response.GetString("UTF8")
File.WriteString(File.DirInternalCache, "students.sco",result)
reader.Initialize(File.OpenInput(File.DirInternalCache, "students.sco"))
Dim line As String
Dim i As Int
i = 0
'line = reader.ReadLine
Do While line <> Null
i = i+1
lstStudents.AddTwoLines(i&". "&line,reader.ReadLine
)
line = reader.ReadLine
Loop
reader.Close
ProgressDialogHide
lstStudents.SetSelection(0)
End Sub
Sub httpC_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Msgbox("Error connecting to students server"&CRLF&CRLF&Reason,"Error ("&StatusCode&")")
ProgressDialogHide
End Sub
Thank you in advance,
microbox